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