编译环境
操作系统:SUSE linux Enterprise Server 10 64-bit
编译工具:gcc 4.1.2
1.下载boost1.36
2.解压boost到/usr/share
3.在命令行运行/usr/share/boost_1_36_0/tools/jam/src/build.sh生成bjam
4.复制/usr/share/boost_1_36_0/tools/jam/src/bin.linuxx86_64/bjam到/usr/bin目录下
5.配置/usr/share/boost_1_36_0/tools/build/v2/user-config.jam中使用的编译工具
using gcc ;
6.使用bjam --build-type=complete --with-XXXX stage 编译指定库或者使用
bjam --build-type=complete stage 完全编译boost库,库文件编译完成后存放在
/usr/share/boost_1_36_0/stage/lib目录下.由于大部分boost库并不需要编译可直接使用,
通常我们可选择性的编译需要的库.
7.如需要使用bjam编译应用程序,编辑/etc/profile,在文件最后增加
export BOOST_ROOT = /usr/share/boost_1_36_0
export BOOST_INCLUDE = /usr/share/boost_1_36_0
export BOOST_LIB = /usr/share/boost_1_36_0/stage/lib
8.为了让编译工具能搜索到boost库的头文件和库文件,我们使用ln命令建立连接
8.1创建头文件连接
ln -s /usr/share/boost_1_36_0/boost /usr/include/boost
8.2创建库文件连接,为了方便我们可使用jam帮助我们完整这项工作,在
/usr/share/boost_1_36_0/stage/lib下创建Jamroot
# Jamroot脚本 local files = [ glob * . * ] ; local curpath ; local install_lib_files = [ glob / usr / lib /* . * ] ; local cmd ; local source_path ; local desc_path ; path - constant curpath : . / ; for local file in $ (files) { source_path = $ (curpath) /$ (file) ; desc_path = " /usr/lib/ " $ (file) ; cmd = " ln -s " $ (source_path) " " $ (desc_path) ; if $ (desc_path) in $ (install_lib_files) { ECHO $ (desc_path) " is exists " ; } else { ECHO $ (cmd) ; SHELL $ (cmd) ; } }
以上脚本将/usr/share/boost_1_36_0/stage/lib目录下的所有库文件创建连接符号到
/usr/lib目录下.
9.编译完成