linux平台下要编译安装除gcc和gcc-c++以外,还须要两个开发库:bzip2-devel 和python-devel,所以在安装前应该先保证这两个库已经安装:html
而后是去官网下载源码包, 地址#yum install gcc gcc-c++ bzip2 bzip2-devel bzip2-libs python-devel -y python
进入boost_1_50_0目录:#tar xvzf boost_1_50_0.tar.gzlinux
#cd boost_1_50_0 c++
而后是编译安装,boost源码包中有配置脚本,直接用就能够:bootstrap
接下来就是编译,重点关注是否编译成功:#sh ./bootstrap.shapp
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 ide
而后就是漫长的等待,若是最后出现:#./b2 ui
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 unix
最后,sudo ./b2 install --prefix=/usr/local code
一、 boost中大部分库是不用编译成动态或者静态连接库。
二、 只有regex,thread等几个库比较麻烦一点.要编译。
三、 若是用gcc编译器-l指定动态连接库的路径,还要指定头文件的路径。
四、 或者连接的boost库放到.c或.cpp以后,不然连接不能经过,编译能够经过。
以下所示:g++ -lz -lpthread hh.c -lboost_filesystem -lboost_thread