你需要到官方網(wǎng)站下載最新的版本,最新已經(jīng)到1.47.0了

1.下載后解壓到/opt/boost_1_47_0

2.解決依賴關(guān)系 sudo apt-get install python-dev gccxml

如果還不全,就用apt-cache depends XXXXXXX查去

3.編譯bjam:

 #cd /opt/boost_1_47_0
 #sudo ./bootstrap.sh

編譯成功

4.編譯boost

 #sudo ./bjam

開始編譯

大約要個十幾分鐘

編譯完成后:

The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
 /home/terry/Local/boost_1_47_0
The following directory should be added to linker library paths:
 /home/terry/Local/boost_1_47_0/stage/lib

因為我是解壓到/home/terry/Local/boost_1_46_1下了

所以編譯完了是這樣的

5.update動態(tài)鏈接庫:

sudo ldconfig

安裝完畢

三,測試使用:

1.測試代碼

#cat test.cpp 
#include <boost/lexical_cast.hpp>
#include <iostream>

int main()
{
 using boost::lexical_cast;
 int a= lexical_cast<int>("123456");
 double b = lexical_cast<double>("123.456");
 std::cout << a << std::endl;
 std::cout << b << std::endl;
 return 0;
}

2.編譯,運行

--g++ -o test test.cpp
#ls
test test.cpp
# ./test 
123456
123.456
贊(0)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享網(wǎng)絡(luò)內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-62778877-8306;郵箱:fanjiao@west.cn。本站原創(chuàng)內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明出處:西部數(shù)碼知識庫 » linux下安裝boost庫的完整步驟記錄

登錄

找回密碼

注冊