简介
Boost is a set of libraries for the C++ programming language that provide support for tasks and structures such as linear algebra, pseudorandom 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
编译前所需的库
sudo apt-get install mpi-default-dev # mpi related
sudo apt-get install libicu-dev # regular expresion related
sudo apt-get install python-dev # python dev related
sudo apt-get install libbz2-dev # I don't know
编译安装boost
tar xf boost_1_58_0.tar.gz
cd boost_1_58_0/
./bootstrap.sh
./b2 -a -sHAVE_ICU= # the parameter means that it support icu or unicode
sudo ./b2 install
测试boost是否安装成功
c++代码(testBoost.cpp)
#include <iostream>
#include <boost/timer.hpp> using namespace boost; int main()
{
timer t;
std::cout << "max timespan:" << t.elapsed_max() / << "h" << std::endl;
std::cout << "min timespan:" << t.elapsed_min() << "s" << std::endl; std::cout << "now itme elapsed:" << t.elapsed() << "s" << std::endl; return EXIT_SUCCESS;
}
编译指令
g++ testBoost.cpp -lboost_system -lboost_filesystem -o testBoost
运行结果