centos 编译安装cmake和常见过程错误解决办法(linux系统均适用,以爬坑。。)

文章目录

    • 下载并编译cmake 3
    • 创建快捷命令
    • 测试版本
    • 报错信息
    • 参考链接

下载并编译cmake 3

# 下载源代码
wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz

# 解压
tar -zxvf cmake-3.10.2.tar.gz  

# 切换目录
cd cmake-3.10.2

# 编译模板预置
./bootstrap --prefix=/usr/local/cmake

# 编译安装
make && make install 

# 卸载自带低版本cmake
yum remove cmake


创建快捷命令

vi /usr/bin/cmake

/usr/local/cmake/bin/cmake $*

测试版本

# 查看版本号
cmake3 -v

报错信息

 [root@cb0ece89d64c cmake-3.10.2]# ./configure --prefix=/usr/local/cmake-3.10.2 && make -j 8 && make install
 ---------------------------------------------
CMake 3.10.2, Copyright 2000-2017 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: /root/codes/cmake-3.10.2/Bootstrap.cmk/cmake_bootstrap.log

解决方法: 安装c++依赖即可,yum install gcc-c++

[root@cb0ece89d64c cmake-3.10.2]# cmake3 --version
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
/usr/share/cmake-3.10
cmake version 3.10.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).

由于根目录问题导致:由于旧的cmake版本卸载不干净导致,通过vi /usr/bin/cmake替换为下面的内容,即可解决

/usr/local/cmake/bin/cmake $*

参考链接

cmake安装源

你可能感兴趣的:(程序设计基础)