Ubuntu20.04安装Cmake指南

安装准备

  1. 若没有make先安装make:sudo apt install make
  2. 安装gcc和g++编译器:
apt install gcc
apt install g++
  1. 下载安装包:(按照下面截图中的版本安装是没问题的,因为之前和现在都安装成功了)
    openssl安装包下载:点击下载地址,进入到网页,选取如下图所示的安装包
Ubuntu20.04安装Cmake指南_第1张图片

进入Cmake官网下载安装包:点击下载链接,进入到网页,选取如下图所示的安装包

# 将这两个安装包放在cmake_install文件夹下,个人喜好配置
root@ubuntu:/usr/local/# mkdir cmake_install
root@ubuntu:/usr/local/# cd cmake_install
root@ubuntu:/usr/local/cmake_install# ls
# cmake-3.18.6.tar.gz  openssl-3.0.0-alpha13.tar.gz

Cmake安装

root@ubuntu:/usr/local/cmake_install# tar -xvf cmake-3.18.6.tar.gz
root@ubuntu:/usr/local/cmake_install# ls
# cmake-3.18.6  cmake-3.18.6.tar.gz  openssl-3.0.0-alpha13.tar.gz
root@ubuntu:/usr/local/cmake_install# cd cmake-3.18.6
root@ubuntu:/usr/local/cmake_install/cmake-3.18.6# ./bootstrap ## 这里需要的时间还是比较长
root@ubuntu:/usr/local/cmake_install/cmake-3.18.6# make
# 然后会报错,如下,说是缺少openssl,接下来就会转到openssl的安装,

#-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: # OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) 
# CMake Error at Utilities/cmcurl/CMakeLists.txt:485 (message):
# Could not find OpenSSL.  Install an OpenSSL development package or
# configure CMake with -DCMAKE_USE_OPENSSL=OFF to build without OpenSSL.

#-- Configuring incomplete, errors occurred!
# See also "/usr/local/cmake_install/cmake-3.18.6/CMakeFiles/CMakeOutput.log".
# See also "/usr/local/cmake_install/cmake-3.18.6/CMakeFiles/CMakeError.log".

# ---------------------------------------------
# Error when bootstrapping CMake:
# Problem while running initial CMake
# ---------------------------------------------

openssl安装

root@ubuntu:/usr/local/cmake_install/cmake-3.18.6# cd ..
root@ubuntu:/usr/local/cmake_install# tar -xvf openssl-3.0.0-alpha13.tar.gz
root@ubuntu:/usr/local/cmake_install# ls
# cmake-3.18.6  cmake-3.18.6.tar.gz  openssl-3.0.0-alpha13  openssl-3.0.0-alpha13.tar.gz
root@ubuntu:/usr/local/cmake_install# cd openssl-3.0.0-alpha13
root@ubuntu:/usr/local/cmake_install/openssl-3.0.0-alpha13# ./config --prefix=/usr/local --openssldir=/usr/local/openssl ## 这里需要的时间也是比较长

完成如下所示:

Ubuntu20.04安装Cmake指南_第2张图片
root@ubuntu:/usr/local/cmake_install/openssl-3.0.0-alpha13# sudo make
# 执行时间还是挺长的
root@ubuntu:/usr/local/cmake_install/openssl-3.0.0-alpha13# sudo make test	
root@ubuntu:/usr/local/cmake_install/openssl-3.0.0-alpha13# sudo make install
# 到此openssl安装完成

再装cmake

root@ubuntu:/usr/local/cmake_install/openssl-3.0.0-alpha13# cd ../cmake-3.18.6   ## 转到cmake目录下
root@ubuntu:/usr/local/cmake_install/cmake-3.18.6# ./bootstrap ## 这里需要的时间还是比较长
root@ubuntu:/usr/local/cmake_install/cmake-3.18.6# make
root@ubuntu:/usr/local/cmake_install/cmake-3.18.6# make install
## cmake测试
root@ubuntu:/usr/local/cmake_install/cmake-3.18.6# cmake --version
# cmake version 3.18.6
# CMake suite maintained and supported by Kitware (kitware.com/cmake).
##至此安装成功

你可能感兴趣的:(杂,cmake,ubuntu,openssl)