導航:首頁 > 操作系統 > linux使用boost

linux使用boost

發布時間:2023-07-16 13:20:27

linux CentOS7系統如何升級boost庫

直接重新下載安裝即可
1.下載 boost
2. 將文件解壓在/usr/local/目錄下
3. 進入/usr/local/boost/ 目錄,寬穗 在terminal中輸入
./bootstrap.sh
4.進入/usr/local/boost/ 目錄,在terminal中輸入
sudo ./bjam --layout=versioned --build-type=complete --toolset=gcc install
5.添加環境變數消緩(剛改完要重啟或者注拿巧模銷一下來更新剛修改過的環境變數)
兩種方法:
(1)修改/etc/profie文件 末尾添加
export BOOST_INCLUDE=/usr/local/include/boost
export BOOST_LIB=/usr/local/lib
(2)在/etc/profile.d/ 中新建一個shell文件boost.sh
#!/bin/sh
export BOOST_INCLUDE=/usr/local/include/boost

export BOOST_LIB=/usr/local/lib

❷ Linux下G++怎麼編譯使用Boost庫的程序

首先把Boost庫的頭文件存放到/usr/include/boost/路徑下,再把Lib文件存放到/usr/local/lib/boost/路徑下。修改/etc/profile文件,在此文件中增加如下2個環境變數:

BOOST_INCLUDE=/usr/include/boost
export BOOST_INCLUDE

BOOST_LIB=/usr/local/lib/boost
export BOOST_LIB

寫一個如下所示的cpp文件。
//samlpe.cpp
#include <iostream>
#include <string>
#include <boost/thread.hpp>

using namespace std;

void threadRoutine(void)
{
boost::xtime time;
time.nsec = 0;
time.sec = 20;
cout << "線程函數做一些事情" << endl;
boost::thread::sleep(time);
}

int main(void)
{
string str;
cout << "輸入任意字元開始創建一個線程..." << endl;
cin >> str;
boost::thread t(&threadRoutine);
t.join();
cout << "輸入任意字元結束運行..." << endl;
cin >> str;
return 0;
}

保存。使用g++編譯,命令如下所示:

g++ -o samlpe.out samlpe.cpp -I$BOOST_INCLUDE -L$BOOST_LIB -lboost_thread-gcc-mt

其中-I參數指定Boost頭文件路徑,-L參數指定Boost庫文件路徑,-l參數指定使用線程庫名。在我使用的這個版本Boost里,到/usr/local/lib/boost路徑下,可以看到有關Boost線程庫文件,比如:libboost_thread-gcc-mt.a等。注意在用-l參數指定庫名時把磁碟文件名前面那個lib前綴去掉就可以了。

❸ 在linux上運行boost庫的問題

我系統是ubuntukylin14.04
然後今天去BOOST下了最新版的boost1.57版

下載下來的壓縮文件畝寬我解壓到/opt目團耐陸錄下即/opt/boost_1_57_0

然後
cd /opt/塌頃boost_1_57_0;
./boststrap;
./b2

這里b2命令執行完成後顯示:
The Boost C++ Libraries were successfully built!

The following directory should be added to compiler include paths:

/opt/boost_1_57_0

The following directory should be added to linker library paths:

/opt/boost_1_57_0/stage/lib

然後我找了一段例子

C/C++ code?

1
2
3
4
5
6
7
8
9
10

#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++編譯的時候提示

bst.cxx:2:31: fatal error: boost/bind.hpp: 沒有那個文件或目錄
#include<boost/bind.hpp>
^
compilation terminated.

閱讀全文

與linux使用boost相關的資料

熱點內容
如何同步安卓信息到新ipad 瀏覽:364
騰訊雲輕量伺服器流量警告 瀏覽:503
u盤備份linux 瀏覽:120
高壓縮比活塞 瀏覽:92
壓縮彈簧標准件 瀏覽:25
linux統計個數命令 瀏覽:292
cad轉pdf居中 瀏覽:8
編譯型語言處理過程 瀏覽:325
手機創文件夾復制到電腦 瀏覽:984
有什麼直播APP可以看那種 瀏覽:41
程序員叫什麼人 瀏覽:378
python畫地圖等高線 瀏覽:751
epic永劫無間是什麼伺服器 瀏覽:444
網游伺服器下載地址 瀏覽:107
macphpfreetype安裝 瀏覽:644
設計道pdf 瀏覽:615
單片機kill4軟體下載收費嗎 瀏覽:846
蘋果手機怎麼連接RMS伺服器 瀏覽:603
cisco路由器基本配置命令 瀏覽:187
android狀態欄顏色透明 瀏覽:117