1. 程式人生 > >安裝新版本Cmake

安裝新版本Cmake

轉載地址:https://askubuntu.com/questions/610291/how-to-install-cmake-3-2-on-ubuntu-14-04

Ubuntu14.04 自帶的Cmake2.8.7 沒有解除安裝,直接下載的原始碼包,編譯,安裝的cmake-3.10,預設安裝的位置是: /usr/local/
 然後在~/.bashrc中 export PATH="$PATH:/usr/local/bin/cmake" 新增到環境變數中。

在原始碼目錄下執行$ ./bootstrap  --prefix=/usr/local/ && make && sudo make install  安裝


安裝完後,$cmake -version, 提示是"cmake version 3.10.0"

在工作空間下編譯catkin包時,因為有的catkin包需要cmake  3.4以上, 錯誤提示當前cmake版本是2.8.7。




網友說的得先解除安裝舊的cmake(sudo apt-get remove cmake),發現這樣的話,會解除安裝很多catkin包,以免以後又得重新安裝,所以最後是借鑑該帖
https://askubuntu.com/questions/610291/how-to-install-cmake-3-2-on-ubuntu-14-04 做的。

因為已經原始碼安裝了新的Cmake, 又按照“Installation by a PPA

”的方式把 自帶的cmake 進行了升級,用的命令"sudo apt-get upgrade" , 再去在工作空間下編譯catkin包時, 錯誤提示Could not find CMAKE_ROOT !!!。 最後又$ sudo apt-get install cmake 後,再去在工作空間下編譯catkin包時通過。

either use a PPA or compile it yourself:

  1. Installation by a PPA (Upgrade to 3.2)

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:george-edison55/cmake-3.x
    sudo apt-get update
    
    • When cmake is not yet installed:

      sudo apt-get install cmake
      
    • When cmake is already installed:

      sudo apt-get upgrade
      
  2. Compile it yourself

    Currently, the latest version is 3.2.2, the following instructions based on this version. You should therefore check this URL and adjust the file name accordingly.

    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
    

    Now you can have to choose an installation type to decide, I recommend installing with checkinstall, as this creates a DEB package.

    • With checkinstall

      sudo apt-get install checkinstall
      sudo checkinstall
      
    • With make install

      sudo make install

####################################################

解除安裝掉ubuntu 14.04 自帶的cmake ($ sudo apt-get  --purge remove cmake )後,用安裝的cmake-3.10 去編譯 android 版的opencv-2.4.13.6,各種出錯,例如: “CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM”, 即使在cmake 時,設定 -DCMAKE_MAKE_PROGRAM=/usr/local/bin/cmake , 又出來新的各種錯誤,j就不一一列舉了。 @()@

最後又把安裝的cmake-3.10 解除安裝掉,重新安裝ubuntu14.04 自帶的cmake-3.2.2($sudo apt-get install cmake ),  再去編譯android版的opencv-2.4.13.6, cmake 時不用設定-DCMAKE_MAKE_PROGRAM,也能通過, make 也通過了。