cmake安装高版本

cmake时报错:

   CMake 3.8 or higher is required.  You are running version 3.5.1

提示目前的cmake版本过低。

安装步骤:

1. 查看当前cmake版本:

cmake -version

2. 卸载当前cmake:(如果安装了ROS跳过此步

sudo apt remove cmake

3. 下载cmake:

  可直接从cmake官网下载新版本,也可执行如下语句:

wget http://www.cmake.org/files/v3.16/cmake-3.16.6.tar.gz

我这里下载的是cmake-3.16.6版本。

或是去文件库下载:https://cmake.org/files/v3.16/

备注:官网给出两种版本,一种是Source版的,另一种是Binary distributions里面的Linux x86_64,这是已经编译好的可执行版,直接拿来用的,只需要建立软连接即可,通过建立软链接调用Cmake-gui来使用cmake。

我这里下载的是以.tar.gz结尾的,source版的。

4. 解压与安装:

tar xf cmake-3.16.6.tar.gz #解压,也可以右键直接提取出来
cd cmake-3.16.6
sudo apt-get install build-essential 

去文件夹看,如果有锁说明有权限设置,返回cmake-3.16.6的上层目录,修改文件权限(没有锁就不用执行这句)

sudo chmod -R 777 cmake-3.16.6
./bootstrap

此步若有报错,看下面的遇到错误的解决办法

make
make install

 

验证:

cmake --version

 

遇到错误的解决办法:

错误1:运行./bootstrap时出现报错:

-- Looking for gethostname
-- Looking for gethostname - found
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) 
CMake Error at Utilities/cmcurl/CMakeLists.txt:454 (message):
  Could not find OpenSSL.  Install an OpenSSL development package or
  configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.


-- Configuring incomplete, errors occurred!
See also "/home/whlg/cmake-3.16.6/CMakeFiles/CMakeOutput.log".
See also "/home/whlg/cmake-3.16.6/CMakeFiles/CMakeError.log".
---------------------------------------------
Error when bootstrapping CMake:
Problem while running initial CMake
---------------------------------------------

提示找不到OpenSSL,查看错误日志,缺少软件包。

解决方案:

sudo apt-get install libssl-dev

再运行

./bootstrap

错误2:make install时出现报错:

[100%] Built target foo
Install the project...
-- Install configuration: ""
CMake Error at Source/kwsys/cmake_install.cmake:41 (file):
  file cannot create directory: /usr/local/doc/cmake-3.16/cmsys.  Maybe need
  administrative privileges.
Call Stack (most recent call first):
  cmake_install.cmake:42 (include)


Makefile:76: recipe for target 'install' failed
make: *** [install] Error 1

解决方案:

sudo make install

错误3:执行cmake --version时提示没有那个文件或目录:

bash: /usr/bin/cmake: 没有那个文件或目录

解决方案:

使用which cmake查找cmake的安装路径,默认是在/usr/local/bin/cmake,而系统会默认去/usr/bin中去寻找。

做一个链接即可:

ln -s /usr/local/bin/cmake /usr/bin 

提示没有权限的话加上sudo。

 

 

 

参考链接:

  How to upgrade cmake in Ubuntu [duplicate]

  Ubuntu学习心得——安装篇——CMake旧版的卸载与新版的安装(防踩坑+两种安装产生的效果)

  CMake的安装及示例

  cmake 没有那个目录

 

posted @ 2020-04-13 12:03  寄生的鱼  阅读(31022)  评论(4编辑  收藏  举报