文章目录
- 0、系列目录
- 1、背景
- 2、操作步骤
- 3、总结
0、系列目录
写这套文章的时候,不会完全按照目录的顺序一篇一篇写, 大家可以到目录中直接找到对应的章节进行查看。
点我跳转
1、背景
安装某些 Python 依赖库的时候,需要特定版本的 Cmake,或者需要高于某些版本的 Cmake,使用 apt 安装的默认版本的 Cmake 版本有些时候会报版本不够的问题,比如:
root@localhost:/root# pip install pyre2
...
running install
running build
running build_ext
CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.15...3.18 or higher is required. You are running version 3.10.2
...
我们查看一下本机的 Cmake 版本:
root@localhost:/root# cmake --version
cmake version 3.10.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
果然,人家要 3.15-3.18,我们本地的是 3.10.2,所以报错了。
2、操作步骤
好了,下面正式开始,如何升级 Cmake。
移除现有 cmake,依次执行以下命令:
cmake --version
hash -r
下载 cmake 目标版本的 sh 文件,下载地址可以在 这里 自行查找。
这里我选择的是 cmake-3.18.6-Linux-x86_64.sh
。
cd /opt
wget https://github.com/Kitware/CMake/releases/download/v3.18.6/cmake-3.18.6-Linux-x86_64.sh
给 sh
脚本可执行权限。
chmod +x cmake-3.18.6-Linux-x86_64.sh
执行 sh
脚本。
./cmake-3.18.6-Linux-x86_64.sh
执行过程中需要同意一下 License
,然后再选择一下安装位置,都同意/默认即可。
执行完成后,再制作一批软连接。
ln -s /opt/cmake-3.18.6-Linux-x86_64/bin/* /usr/local/bin/
最后检查一下更新之后的 cmake 版本。
root@localhost:/opt# cmake --version
cmake version 3.18.6
CMake suite maintained and supported by Kitware (kitware.com/cmake).
大功告成。
3、总结
升级 Cmake 的方法有很多,还可以手动编译安装、使用 snap
安装,这里我们只介绍了使用 sh
脚本安装的方式。
需要注意的就是,在安装之前要先卸载旧版本的 cmake
。
以上。
祝大家变的更强。