linux 下如何升级CMAKE?(安装指定版本cmake)(高版本cmake)(不删除之前的,可以用软链接)

先把当前版本全卸载

# sudo apt remove cmake
# sudo apt purge --auto-remove cmake

然后到cmake官网下载指定.sh版本

https://cmake.org/files/

我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).

参考文章:如何指定在Ubuntu中安装CMake的位置?

20210929 但是卸载不知道怎么卸载,尴尬了。。。。

20220209 貌似原来cmake不需要卸载,直接安装新的然后做个软连接就好了

参考文章:ubuntu16.04升级cmake版本,可任意切换版本

https://cmake.org/files/

下这个:
在这里插入图片描述
以 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老版本的位置,重新做一次软连接)

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dontla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值