Loading

Ubuntu安装CMake(源码编译安装)

1.更换镜像源

# 编辑镜像源文件
sudo vi /etc/apt/sources.list

# 写入以下内容
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

# 更新镜像源
sudo apt update

2.安装gcc

sudo apt install gcc

3.安装g++

sudo apt install g++

4.检查是否存在cmake

which cmake

# 如果显示路径说明包含cmake,需要移除
sudo apt-get remove cmake

5.下载cmake

# 下载网站 https://cmake.org/download/
wget 下载链接

6.解压

# 在cmake源码所在文件夹中打开命令终端,解压文件
tar -zxvf cmake-3.23.2.tar.gz

7.进入解压后的cmake文件进行检查

cd cmake-3.23.2

# 检查
./bootstrap

8.检查报错及解决方法

image.png

# 安装openssl系统
sudo apt-get install libssl-dev

# 再次检查
./bootstrap

9.编译构造

sudo make

10.安装

sudo make install

11.检查

# 查看cmake版本
cmake --version

# 查看cmake位置
which cmake
posted @ 2022-06-10 14:35  励码万言  阅读(471)  评论(0编辑  收藏  举报