考虑到有些库需要高版本才能进行编译。这里提供一个从源码安装较新版本的方法,其实也很简单:
查看当前版本:
cmake --version
root@ubuntu:/home/share/gitcode/sdl6008# cmake --version
cmake version 2.8.12.2
下载源码:
https://cmake.org/files/v3.13/
cmake-3.13.1.tar.gz
解压缩并进入文件夹:
tar -zxvf cmake-3.13.1.tar.gz
cd cmake-3.13.1
编译安装:
./bootstrap
make
sudo make install
source ~/.bashrc
再次查看当前版本:
cmake --version
root@ubuntu:/home/share/cmake-3.13.1# cmake --version
bash: /usr/bin/cmake: No such file or directory
vi ~/.bashrc
添加
export PATH=/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
wq
source ~/.bashrc
vi ~/.profile
添加
export PATH=/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
source ~/.profile
再次查看 cmake --version
root@ubuntu:/home/share/cmake-3.13.1# cmake --version
cmake version 3.13.1
CMake suite maintained and supported by Kitware (kitware.com/cmake).
参考:https://blog.csdn.net/luo870604851/article/details/80725584