Ubuntu16.04 安装boost1.65

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

参考: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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值