前言
Boost庫是一個可移植、提供源代碼的C++庫,作為標準庫的后備,是C++標準化進程的開發(fā)引擎之一。 Boost庫由C++標準委員會庫工作組成員發(fā)起,其中有些內(nèi)容有望成為下一代C++標準庫內(nèi)容。在C++社區(qū)中影響甚大,是不折不扣的“準”標準庫。Boost由于其對跨平臺的強調(diào),對標準C++的強調(diào),與編寫平臺無關。
在linux安裝過程如下:
去官方網(wǎng)站下載最新的:http://sourceforge.net/projects/boost/files/boost/1.47.0/ or www.boost.org
一,最簡單的方法:
搜到所有的boost庫
然后:
sudo apt-get install libboost-all-dev
安裝相應的庫
二,編譯安裝,
你需要到官方網(wǎng)站下載最新的版本,最新已經(jīng)到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
開始編譯
大約要個十幾分鐘
編譯完成后:
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)鏈接庫:
安裝完畢
三,測試使用:
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
總結:
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。