新闻  |   论坛  |   博客  |   在线研讨会
在linux下编译boost库
hikesoso2010 | 2011-02-28 19:27:27    阅读:1462   发布文章

96堆栈 软件编程网- http://www.96dz.com,提供C语言、C++编程、VC++编程、Java编程、C#编程、NET编程、Linux编程、Web编程等全面技术信息,编程开发教程、视频教程、培训教程及相关资料的下载。

  编译环境

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

 96堆栈 软件编程网- http://www.96dz.com,提供C语言、C++编程、VC++编程、Java编程、C#编程、NET编程、Linux编程、Web编程等全面技术信息,编程开发教程、视频教程、培训教程及相关资料的下载。

*博客内容为网友个人发布,仅代表博主个人观点,如有侵权请联系工作人员删除。

参与讨论
登录后参与讨论
嵌入式系统,Linux,WinCE,单片机,ARM,DSP,EDA,FPGA,CPLD,PLC,数电,模电,PCB,硬件设计,软件编程,应用电子技术,视频教程、培训视频、教程资料、学习教程,海量资源下载中心, 海科资源
推荐文章
最近访客