linux_centos 安装 cmake


linux_centos 安装 cmake

卸载已安装的 cmake

cmake --version

# 若已安装版本以满足我们需求,则不需要更新安装
# 如果已安装版本不符合我们需求,则下卸载旧版

yum remove -y cmake

下载 cmake

前往官网 CMake 下载我们需要的版本,我们 下载最新稳定版3.26.4 并安全验证。

curl -OL https://cmake.org/files/v3.26/cmake-3.26.4-SHA-256.txt
curl -OL https://cmake.org/files/v3.26/cmake-3.26.4.tar.gz

-- 安全验证:
[root@pudding cmake]# sha256sum -c cmake-3.26.4-SHA-256.txt
# 其他版本未找到日志已忽略
cmake-3.26.4.tar.gz: OK
sha256sum: WARNING: 16 listed files could not be read

解压,编译安装

tar zxvf cmake-3.26.4.tar.gz && cd cmake-3.26.4

./bootstrap && gmake && gmake install

缺少 c/c++ 编译环境:

[root@pudding cmake-3.26.4]# ./bootstrap && gmake && gmake install
---------------------------------------------
CMake 3.26.4, Copyright 2000-2023 Kitware, Inc. and Contributors
---------------------------------------------
Error when bootstrapping CMake:
Cannot find appropriate C compiler on this system.
Please specify one using environment variable CC.
See cmake_bootstrap.log for compilers attempted.

---------------------------------------------
Log of errors: /home/work/cmake-3.26.4/Bootstrap.cmk/cmake_bootstrap.log
---------------------------------------------

安装 gcc|g++

sudo yum -y install gcc gcc-c++ kernel-devel

gcc --version
g++ --version

建立软链接

[root@pudding cmake-3.26.4]# /usr/local/bin/cmake --version
cmake version 3.26.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@pudding cmake-3.26.4]# ln -s /usr/local/bin/cmake /usr/bin
[root@pudding cmake-3.26.4]# cmake --version
cmake version 3.26.4

CMake suite maintained and supported by Kitware (kitware.com/cmake).

文章作者: Pudding
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Pudding !
  目录