Ubuntu16.04搭建boost环境

 

下载地址: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库路径写入配置文件。
echo "/usr/local/lib/boost" >> /etc/ld.so.conf.d/usr_local_lib.conf
ldconfig

 

测试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;
}
Makefile:
FLAG +=-std=c++11
FLAG += -g -Wall
FLAG += -O0
SRC += main.cpp
GCC = g++
DEMO= DEMO
demo:
        $(GCC) $(FLAG) $(SRC) -o $(DEMO)
clean:
        rm DEMO

 

posted @ 2018-09-27 21:36  osbreak  阅读(5500)  评论(0编辑  收藏  举报