- 安装命令
sudo apt install cmake
注意此方式安装的可能不是最新版本的Cmake
- Cmake源码编译安装
# 卸载原来的cmake
sudo apt-get remove cmake
#下载cmake源码
wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1.tar.gz
# 解压
tar -zxv -f cmake-3.24.1.tar.gz
cd cmake-3.24.1
./bootstrap
# 编译构建
make
# 安装
sudo make install
# 查看安装版本
cmake --version
安装过程中报错:
Error when bootstrapping CMake:
Cannot find a C++ compiler that supports both C++11 and the specified C++ flags.
Please specify one using environment variable CXX.
The C++ flags are "".
They can be changed using the environment variable CXXFLAGS.
See cmake_bootstrap.log for compilers attempted.
- 执行
sudo apt-get install g++
或
sudo yum install -y gcc gcc-c++ --allowerasing