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源码包中有配置脚本,直接用就可以:

#
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


最后,sudo ./b2 install --prefix=/usr/local


1、  boost中大部分库是不用编译成动态或者静态链接库。

2、  只有regex,thread等几个库比较麻烦一点.要编译。

3、  如果用gcc编译器-l指定动态链接库的路径,还要指定头文件的路径。

4、  或者链接的boost库放到.c或.cpp之后,否则链接不能通过,编译可以通过。

如下所示:g++ -lz -lpthread hh.c -lboost_filesystem -lboost_thread


5,

安装完毕后的头文件默认是在/usr/local/include目录下,.a.so/usr/local/lib目录下。

然后将需要使用的库sudo cp/usr/lib 。不然在执行代码时,ldd会提示找不到.so文件。

./main: error while loading shared libraries: libboost_serialization.so.1.52.0: cannot open shared object file: No such file or directory

 

      本文转自crazy_charles 51CTO博客,原文链接:http://blog.51cto.com/douya/1928261http://blog.51cto.com/douya/1928261 ,如需转载请自行联系原作者




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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值