CentOS 5.5的內(nèi)核版本是2.6.18-194.e15 GCC版本是4.1.2 (20080704)
CentOS 5.5自帶的boost 1.33,這個(gè)版本比較老了,幾年前的版本。主要是,這個(gè)版本沒(méi)有ASIO。所以決定重新編譯一個(gè)boost。
首先去http://www.boost.org/下載一個(gè)最新的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、進(jìn)入boost_1_45_0目錄中,運(yùn)行./bootstrap.sh,完成后會(huì)得到一個(gè)bjam
3、然后開(kāi)始編譯: ./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庫(kù)文件了。
雖然usr/local/include和/usr/include都有目錄,但GCC是先訪問(wèn)/usr/local/include,所以編譯完成后,就可以默認(rèn)使用boost了。
5、下面做一個(gè)測(cè)試。
輸入:vi testboost.cpp,然后輸入如下代碼
運(yùn)行:./testboost
結(jié)果:104500
這樣,就完成了boost編譯。
CentOS 5.5自帶的boost 1.33,這個(gè)版本比較老了,幾年前的版本。主要是,這個(gè)版本沒(méi)有ASIO。所以決定重新編譯一個(gè)boost。
首先去http://www.boost.org/下載一個(gè)最新的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、進(jìn)入boost_1_45_0目錄中,運(yùn)行./bootstrap.sh,完成后會(huì)得到一個(gè)bjam
3、然后開(kāi)始編譯: ./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庫(kù)文件了。
雖然usr/local/include和/usr/include都有目錄,但GCC是先訪問(wèn)/usr/local/include,所以編譯完成后,就可以默認(rèn)使用boost了。
5、下面做一個(gè)測(cè)試。
輸入: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 testboost2 #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
運(yùn)行:./testboost
結(jié)果:104500
這樣,就完成了boost編譯。