centos7升级 cmake

2023-05-16

一、删除旧版本cmake

升级到最新版本前应事先删除旧版本内核。

cmake -version
yum remove -y cmake

二、安装需要的模块

yum install -y libxml2 libxml2-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel zstd libzstd-devel curl libpng libpng-devel

三、下载cmake源代码

官网地址为https://cmake.org,选择download中的源代码文件。

wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1.tar.gz
tar -zxvf cmake-3.24.1.tar.gz

四、编译cmake

建立 cmake-3.24.1-bulid 目录,在该目录中执行 cmake-3.24.1 目录中的 configure 命令,可在该目录中生成编译文件,不影响 cmake-3.24.1 源代码目录的文件结构。

mkdir cmake-3.24.1-build
cd cmake-3.24.1-build
../cmake-3.24.1/configure --prefix=/usr/local/cmake-3.24.1
gmake -j2 # 2核服务器配置的参数
# make install
gmake install
cd ..

五、配置环境

#设置环境变量
touch /etc/profile.d/cmake.sh
chmod 777 /etc/profile.d/cmake.sh 
echo -e '\nexport PATH=/usr/local/cmake-3.24.1/bin:$PATH\n' >> /etc/profile.d/cmake.sh
source /etc/profile.d/cmake.sh

用 reboot 重启服务器。 

六、查看cmake版本

cmake -version

七、cmake编译libzip的演示

 1.下载

yum remove -y libzip libzip-devel
wget https://libzip.org/download/libzip-1.9.2.tar.gz --no-check-certificate
tar -zxvf libzip-1.9.2.tar.gz

 2.编译

mkdir libzip-1.9.2-build
cd libzip-1.9.2-build
cmake ../libzip-1.9.2 --install-prefix /usr/local/libzip-1.9.2
cmake --build .
cmake --install .
cd ..

3.配置

# 设置环境变量
touch /etc/profile.d/libzip.sh
chmod 777 /etc/profile.d/libzip.sh 
echo -e '\nexport PATH=/usr/local/libzip-1.9.2/bin:$PATH\nexport PKG_CONFIG_PATH=/usr/local/libzip-1.9.2/lib64/pkgconfig:$PKG_CONFIG_PATH' >> /etc/profile.d/libzip.sh
source /etc/profile.d/libzip.sh

# 设置库文件
touch /etc/ld.so.conf.d/libzip.conf
chmod 777 /etc/ld.so.conf.d/libzip.conf 
echo -e "/usr/local/libzip-1.9.2/lib64" >> /etc/ld.so.conf.d/libzip.conf
ldconfig -v
 
#显示动态连接库
ldconfig -p |grep libzip

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

centos7升级 cmake 的相关文章

随机推荐