随笔 - 2, 文章 - 0, 评论 - 0, 引用 - 0
数据加载中……

编译最新版boost库

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编译。

posted on 2010-12-21 16:53 冯旭飞 阅读(516) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理