首先下載源碼包
http://www.cmake.org/cmake/resources/software.html
這里下載的是cmake-2.8.9.tar.gz
隨便找個目錄解壓縮
1 |
tar -xzvf cmake-2.8.9. tar .gz |
2 |
cd cmake-cmake-2.8.9 |
依次執行:
1 |
./bootstrap |
2 |
make |
3 |
make install |
cmake 會默認安裝在 /usr/local/bin 下面
要改變安裝路徑,在bootstrap命令中加入'--prefix=PATH'選項。
二、linux下安裝boost
linux平臺下要編譯安裝除gcc和gcc-c++之外,還需要兩個開發庫:bzip2-devel 和python-devel,因此在安裝前應該先保證這兩個庫已經安裝:
然后是去官網下載源碼包,地址#yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y
下載,解壓,按照如下步驟:
進入boost_1_50_0目錄:#tar xvzf boost_1_50_0.tar.gz
#cd boost_1_50_0
然后是編譯安裝,boost源碼包中有配置腳本,直接用就可以:
接下來就是編譯,重點關注是否編譯成功:#sh ./bootstrap.sh
Building Boost.Build engine with toolset gcc... tools/build/v2/engine/bin.linuxx86_64/b2
Detecting Python version... 2.6
Detecting Python root... /usr
Unicode/ICU support for Boost.Regex?... not found.
Generating Boost.Build configuration in project-config.jam...
Bootstrapping is done. To build, run:
./b2
To adjust configuration, edit 'project-config.jam'.
Further information:
- Command line help:
./b2 --help
- Getting started guide:
http://www.boost.org/more/getting_started/unix-variants.html
- Boost.Build documentation:
http://www.boost.org/boost-build2/doc/html/index.html
然后就是漫長的等待,如果最后出現:#./b2
表示編譯成功,如果沒有成功,就需要回查看哪里出現error,再安裝相應的庫,The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
/home/gang/BAK/boost_1_50_0
The following directory should be added to linker library paths:
/home/gang/BAK/boost_1_50_0/stage/lib
最后就是安裝:
安裝后的頭文件在/usr/local/include/boost里面,而相應的庫在/usr/local/lib/libboost_*#./b2 install --prefix=/usr/local