cmake与boost (muduo的准备工作)

一、 linux下安装cmake

首先下载源码包
        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

然后是去官网下载源码包,地址
下载,解压,按照如下步骤:

#tar xvzf boost_1_50_0.tar.gz

进入boost_1_50_0目录:

#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

然后就是漫长的等待,如果最后出现:

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

表示编译成功,如果没有成功,就需要回查看哪里出现error,再安装相应的库,
最后就是安装:

#./b2 install --prefix=/usr/local

安装后的头文件在/usr/local/include/boost里面,而相应的库在/usr/local/lib/libboost_*

你可能感兴趣的:(cmake与boost (muduo的准备工作))