目录

Boost

misaraty 更新 | 2022-01-15
前言
Boost是基于C++扩展库。

安装与运行

测试文件test.cpp
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#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;
}

Boost1.67

  • 安装
1
2
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中添加,

1
2
3
4
5
#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
  • 运行
1
g++ test.cpp -o test && ./test

Boost1.60

  • 安装
1
2
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中添加,

1
2
3
4
5
6
#boost
# 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