Ubuntu 14.04 編譯安裝 boost 1.58


簡介

Boost is a set of libraries for the C++ programming language that provide support for tasks and structures such as linear algebrapseudorandom number generation, multithreading, image processing,regular expressions, and unit testing. It contains over eighty individual libraries.(From Wiki)

安裝步驟

下載地址:http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download

編譯前所需的庫

1 sudo apt-get install mpi-default-dev # mpi related
2 sudo apt-get install libicu-dev # regular expresion related
3 sudo apt-get install python-dev # python dev related
4 sudo apt-get install libbz2-dev # I don't know

編譯安裝boost

1 tar xf boost_1_58_0.tar.gz
2 cd boost_1_58_0/
3 ./bootstrap.sh
4 ./b2 -a -sHAVE_ICU=1 # the parameter means that it support icu or unicode
5 sudo ./b2 install

測試boost是否安裝成功

c++代碼(testBoost.cpp)

 1 #include <iostream>
 2 #include <boost/timer.hpp>
 3 
 4 using namespace boost;
 5 
 6 int main()
 7 {
 8         timer t;
 9         std::cout << "max timespan:" << t.elapsed_max() / 3600 << "h" << std::endl;
10         std::cout << "min timespan:" << t.elapsed_min() << "s" << std::endl;
11 
12         std::cout << "now itme elapsed:" << t.elapsed() << "s" << std::endl;
13 
14         return EXIT_SUCCESS;
15 }

編譯指令

1 g++ testBoost.cpp -lboost_system -lboost_filesystem -o testBoost

運行結果


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM