如何在Ubuntu上安装cmake 3.2

默认的cmake版本14.04是2.8。 如何安装cmake 3.2并替换默认的? 或者如何将2.8升级到3.2?

要么使用PPA,要么自己编译:

  1. 通过PPA安装(升级到3.2)

    sudo apt-get install software-properties-common sudo add-apt-repository ppa:george-edison55/cmake-3.x sudo apt-get update 
    • 当尚未安装cmake时:

       sudo apt-get install cmake 
    • 当已安装cmake时:

       sudo apt-get upgrade 
  2. 自己编译

    目前,最新版本是3.2.2,以下说明基于此版本。 因此,您应该检查此URL并相应地调整文件名。

     sudo apt-get install build-essential wget http://www.cmake.org/files/v3.2/cmake-3.2.2.tar.gz tar xf cmake-3.2.2.tar.gz cd cmake-3.2.2 ./configure make 

    现在您必须选择安装类型来决定,我建议使用checkinstall安装,因为这会创建一个DEB包。

    • 使用checkinstall

       sudo apt-get install checkinstall sudo checkinstall 
    • 随着make install

       sudo make install 

有三种选择:

  • 从PPA安装
  • 从cmake.org安装预构建的二进制发行版
  • 自己编译

从PPA安装

 sudo add-apt-repository ppa:george-edison55/cmake-3.x sudo apt-get update 

当尚未安装cmake时:

 sudo apt-get install cmake 

当已安装cmake时:

 sudo apt-get upgrade 

从cmake.org二进制distrubtion安装

 curl -sSL https://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz | sudo tar -xzC /opt 

CMake可执行文件将位于/opt/cmake-3.5.2-Linux-x86_64/bin/

自己编译

目前,最新版本为3.5.2,以下说明基于此版本。 因此,您应该检查下载页面并相应地调整文件名。

 sudo apt-get install build-essential wget http://www.cmake.org/files/v3.5/cmake-3.5.2.tar.gz tar xf cmake-3.5.2.tar.gz cd cmake-3.5.2 ./configure make 

现在您必须选择安装类型来决定,我建议使用checkinstall安装,因为这会创建一个DEB包。

  • 使用checkinstall

     sudo apt-get install checkinstall sudo checkinstall 
  • make install

     sudo make install 

我不确定我是否迟到了,但最近在Ubuntu 14.04我遇到了同样的问题,这就是我如何解决它。 首先,您需要通过执行以下命令来删除现有的cmake

sudo apt-get remove cmake

点击返回进入 。 接下来,您需要使用以下命令安装cmake3

 sudo apt-get update sudo apt-get upgrade sudo apt-get install cmake3 

假设,我的答案将在几年后变老,考虑搜索一个与之关联的数字的cmake包。 例如,在这个时候,cmake3适合我。

要做到这一点,你必须执行的就是

apt-cache search cmake

找到包后,只需按照建议安装即可。

谢谢
快乐的编码!

尝试从源代码构建它,安装它并调整$ PATH变量以使其可用。 也许你应该将导出的变量添加到你的bashrc中。 这基本上就是我要做的,请根据需要更改文件和文件夹名称:

 sudo apt-get install build-essential wget http://url.to/cmake-3.2-src.tar.gz tar xzf cmake-3.2-src.tar.gz cd cmake-3.2-src ./configure make # If make finishes without errors: sudo make install export PATH=/usr/local/bin:$PATH export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH cmake --version # This should give v3.2 

只需从https://cmake.org/download/安装sh中的最新版本即可

 cd /usr sudo wget https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.sh -P /usr/ sudo chmod 755 /usr/cmake-3.8.2-Linux-x86_64.sh sudo ./cmake-3.8.2-Linux-x86_64.sh