Boost

Boost是基于C++扩展库。下载boost_1_67_0.zip,运行以下代码安装,

unzip boost_1_67_0.zip && cd boost_1_67_0 && ./bootstrap.sh --with-libraries=all --prefix=/backup/home/misaraty/soft/boost1.67
./b2 install -j 16

然后,在.bashrc中增加环境变量,

#boost
export C_INCLUDE_PATH=/backup/home/misaraty/soft/boost1.67/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/backup/home/misaraty/soft/boost1.67/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/backup/home/misaraty/soft/boost1.67/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/backup/home/misaraty/soft/boost1.67/lib:$LIBRARY_PATH

测试文件test.cpp代码如下,

#include <string>
#include <iostream>
#include <boost/version.hpp>
#include <boost/timer.hpp>

using namespace std;

int main()
{
boost::timer t;

cout << "max timespan: " << t.elapsed_max() / 3600 << "h" << endl;
cout << "min timespan: " << t.elapsed_min() << "s" << endl;
cout << "now time elapsed: " << t.elapsed() << "s" << endl;

cout << "boost version" << BOOST_VERSION <<endl;
cout << "boost lib version" << BOOST_LIB_VERSION <<endl;

return 0;
}

运行以下命令进行测试,

g++ test.cpp -o test && ./test

若为boost_1_60_0.tar.gz安装,先export对应的Python的环境变量,然后

rm -rf boost_1_60_0 && mkdir boost1.60 && tar -zxvf boost_1_60_0.tar.gz && cd boost_1_60_0 && ./bootstrap.sh --with-libraries=all && ./b2 -j 20
./b2 install --prefix=/home/misaraty/soft/boost1.60

tar -zxvf boost_1_60_0.tar.gz也可替换为tar -jxvf boost_1_60_0.tar.bz2

然后,在.bashrc中增加环境变量,

# boost1.60
export C_INCLUDE_PATH=/home/misaraty/soft/boost1.60/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/home/misaraty/soft/boost1.60/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=/home/misaraty/soft/boost1.60/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=/home/misaraty/soft/boost1.60/lib:$LIBRARY_PATH