转载地址: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:
-
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
-
-
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 , 又出来新的各种错误,就不一一列举了。 @()@
最后又把安装的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 也通过了。