在linux下编译boost库【搜集】

http://www.cnblogs.com/flywuya/archive/2010/11/30/1892483.html


 编译环境

  操作系统: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.编译完成


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值