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編譯。