你需要到官方網站下載最新的版本,最新已經到1.47.0了

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

2.解決依賴關系 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動態鏈接庫:

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)
聲明:本網站發布的內容(圖片、視頻和文字)以原創、轉載和分享網絡內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。郵箱:3140448839@qq.com。本站原創內容未經允許不得轉載,或轉載時需注明出處:三五互聯知識庫 » linux下安裝boost庫的完整步驟記錄

登錄

找回密碼

注冊