Ubuntu安装boost库


boost中,用到了别的函数库,所以为了使用boost中相应的功能,需要先安装系统中可能缺失的库。

第一步: 安装依赖库

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

第二步:下载安装boost或直接安装boost

  • 直接安装
sudo apt-get install libboost-dev
tar -jxvf xx.tar.bz2

解压之后,进入解压目录,执行:

./bootstrap.sh
sudo ./b2
sudo ./b2 install

PS : boost的安装时间还是很长的,单核的虚拟机上面 30 min 左右。

第三步:测试

#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;
}

原文1:https://blog.csdn.net/faihung/article/details/88128928
原文2:https://blog.csdn.net/zhangxiao93/article/details/51077933


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM