安装教程

 

直接安装
sudo apt-get install libboost-dev

从源码安装
下载 https://www.boost.org/ 压缩包 解压
sudo apt-get install mpi-default-dev  #安装mpi库
sudo apt-get install libicu-dev     #支持正则表达式的UNICODE字符集
sudo apt-get install python-dev     #需要python的话
sudo apt-get install libbz2-dev     #如果编译出现错误:bzlib.h: No such file or directory

#编译 默认路径是 /usr/local/include 和 /usr/local/lib,分别存放头文件和各种库
sudo ./bootstrap.sh
#安装
sudo ./b2 install

 

  工程引用

 

camke(3)配置boost_ico

 

 

 

CMakeLists.txt

# cmake needs this line
cmake_minimum_required(VERSION 3.1)

# Define project name
project(boost_example_project)



find_package(Boost COMPONENTS regex system REQUIRED)


include_directories(${Boost_INCLUDE_DIRS})

MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.")
MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.")
MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.")

add_executable(boost_example example.cpp)
target_link_libraries (boost_example ${Boost_LIBRARIES})

  

example.cpp

 

#include<iostream>
#include<boost/bind.hpp>
using namespace std;
using namespace boost;
int fun(int x,int y){return x+y;}
int main(){
	int m=1;int n=2;
	cout<<boost::bind(fun,_1,_2)(m,n)<<endl;
	return 0;
}

 

使用编译

 

mkdir build
cd build
cmake ..
make
./boost_example

camke(3)配置boost_正则表达式_02