原
先把当前版本全卸载
# sudo apt remove cmake
# sudo apt purge --auto-remove cmake
注意:运行
apt purge --auto-remove cmake
命令将会从您的系统中完全删除cmake
包以及其安装时自动安装的、但未被其他软件包使用的依赖包。这个命令的purge
部分意味着它还会删除所有相关的配置文件。如果您只是使用
cmake
来构建一些项目,并没有其他软件直接依赖于cmake
的话,这个命令通常不会删除系统中的重要组件或影响系统稳定性。但如果您的系统上有软件包依赖于cmake
作为其功能的一部分(这比较少见),那么这些依赖cmake
的软件包也可能被删除。在执行这样的操作前,建议检查一下是否有其他软件包依赖于
cmake
。可以使用以下命令来检查:bash apt rdepends --installed cmake
这个命令会列出所有已安装的依赖于
cmake
的软件包。如果列表为空或只包含知道是因为手动安装的包,那么可以安全地卸载cmake
。如果看到了其他软件包,最好检查这些包是否还需要cmake
。
然后到cmake官网下载指定.sh版本
我i下这个
下完后复制到虚拟机里
终端运行
sudo ./cmake-3.8.0-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
如果提示没权限就赋予777权限
详细指令:
root@ubuntu:/home/yg/share# ./cmake-3.8.0-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
bash: ./cmake-3.8.0-Linux-x86_64.sh: 权限不够
root@ubuntu:/home/yg/share#
root@ubuntu:/home/yg/share#
root@ubuntu:/home/yg/share# chmod 777 cmake-3.8.0-Linux-x86_64.sh
root@ubuntu:/home/yg/share#
root@ubuntu:/home/yg/share#
root@ubuntu:/home/yg/share#
root@ubuntu:/home/yg/share# ./cmake-3.8.0-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr/local
CMake Installer Version: 3.8.0, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /usr/local
Using target directory: /usr/local
Extracting, please wait...
Unpacking finished successfully
root@ubuntu:/home/yg/share#
root@ubuntu:/home/yg/share#
root@ubuntu:/home/yg/share#
测试版本:
root@ubuntu:/home/yg/share# cmake --version
cmake version 3.8.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
20210929 但是卸载不知道怎么卸载,尴尬了。。。。
20220209 貌似原来cmake不需要卸载,直接安装新的然后做个软连接就好了
参考文章:ubuntu16.04升级cmake版本,可任意切换版本
下这个:
以 3.13.0 版本为例:(嫌用wget下太慢用迅雷下好再扔进Ubuntu里)
以下几个步骤分别为:下载、解压、移动、建立软连接
wget https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz
tar -xzvf cmake-3.13.0-Linux-x86_64.tar.gz
sudo mv cmake-3.13.0-Linux-x86_64 /opt/cmake-3.13.0
sudo ln -sf /opt/cmake-3.13.0/bin/* /usr/bin/
cmake --version
结果:
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]5# cmake --version
cmake version 3.5.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]6#
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]6#
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]6#
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]6# sudo ln -sf /opt/cmake-3.13.0/bin/* /usr/bin/
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]7#
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]7#
[root@ubuntu /home/arnold/Arnold_test/20220209_cmake3.13]7# cmake --version
cmake version 3.13.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
可以看到,cmake的版本变化了,但其实之前的并没有删除
如果要删除软连接,直接重新做一下软连接就可以了(不过应该要先到/usr/bin里删除软连接,然后找到cmake3.5.1老版本的位置,重新做一次软连接)