参考: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

博客介绍了Boost库的使用步骤,包括从指定链接下载源码,下载后会生成b2和bjam文件,可查看其使用方法;接着进行编译,还介绍了建立test.cpp文件、编译、执行等操作。

1万+

被折叠的 条评论
为什么被折叠?



