ubuntu14.04 boost 1.58.0 安裝

1.首先下载安装包,然后解压, 切换目录

wget -o boost_1_58_0.gar.gz http://sourceforge.net/projects/boost/files/boost/1.58.0/boost_1_58_0.tar.bz2/download
tar xf boost_1_58_0.tar.gz
cd boost_1_58_0

2. 编译前安装必要的库

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

3. 编译安装boost

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

4. 测试boost是否安装成功

c++代码(testBoost.cpp)

 #include <iostream>
#include <boost/timer.hpp> using namespace boost; int main()
{
timer t;
std::cout << "max timespan:" << t.elapsed_max() / 3600 << "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
./testBoost

运行结果

max timespan:  ....

min timespan:  ....

上一篇:详解MySQL 内连接、外连接、左连接、右连接


下一篇:Python常用数据结构之collections模块