参考:https://blog.csdn.net/jiandanjinxin/article/details/65632653
##1. 下载源码
https://www.boost.org/users/history/version_1_65_1.html
tar -zxvf boost_1_65_1.tar.gz
cd boost_1_65_1
./bootstrap.sh --with-python=PYTHON
./bootstrap.sh –with-libraries=all
会生成 b2和bjam文件。可查看使用方法
./bootstrap.sh -help
##2. 编译 boost
sudo ./b2 install
./b2 cxxflags=-fPIC cflags=-fPIC --c++11
3. 建立test.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;
}
编译
g++ test.cpp -o test
执行
./test
结果:
3