安装、编译boost

239 篇文章 2 订阅

CentOS 5.5的内核版本是2.6.18-194.e15 GCC版本是4.1.2 (20080704)
CentOS 5.5自带的boost 1.33,这个版本比较老了,几年前的版本。主要是,这个版本没有ASIO。所以决定重新编译一个boost。
首先去http://www.boost.org/下载一个最新的boost 1.45.
下载http://sourceforge.net/projects/boost/files/boost/1.45.0/boost_1_45_0.tar.gz/download到home目录中
1、输入命令tar xzvf boost_1_45_0.tar.gz 解压到目录boost_1_45_0
2、进入boost_1_45_0目录中,运行./bootstrap.sh,完成后会得到一个bjam
3、然后开始编译: ./bjam --with-date_time --with-system --with-regex --with-thread --with-filesystem --with-serialization --with-iostreams --with-math --with-mpi --with-program_options --with-python --with-math --with-signals --layout=tagged install variant=debug,release link=static --runtime-link=static threading=multi stage
4、编译完成后,在/usr/local/include/boost就有最新的boost头文件了,在/usr/local/lib就有编译好的.a库文件了。
虽然usr/local/include和/usr/include都有目录,但GCC是先访问/usr/local/include,所以编译完成后,就可以默认使用boost了。
5、下面做一个测试。
输入:vi testboost.cpp,然后输入如下代码
  1 #include <iostream>
  2 #include <boost/version.hpp>
  3
  4 int main(int argc, char * argv[])
  5 {
  6     std::cout<<BOOST_VERSION<<std::endl;
  7     return 0;
  8 }
  9 编译:g++ testboost.cpp -o testboost
运行:./testboost
结果:104500
这样,就完成了boost编译。

转自:http://www.iieeg.com/newscon.php?id=781


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值