導航:首頁 > 程序命令 > boost命令

boost命令

發布時間:2023-09-07 21:26:26

㈠ 在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.

㈡ boost源碼如何應用

下載Boost庫,這里我選擇下載boost_1_55_0.zip
解壓boost文件到本地目錄(如G:\boost_1_55_0),可以發現解壓後的文件中有一個bootstrap.bat文件。
然後以管理員身份打開cmd窗口,

上述命令執行完畢後可以發現G:\boost_1_55_0下新生成了一個bjam.exe文件
在命令窗口中輸入語句:bjam.exe
此過程將默認根據系統已經安裝好的編譯工具(VS2008,2010,2012,2013)等編譯相應的Lib文件、頭文件等。(此步驟大概需要10分鍾)
可以看到msvc 12.0,這是因為我系統中已經安裝過了VS2013
msvc : 8.0是VS2005
msvc : 10.0是VS2010
msvc : 12.0是VS2012、VS2013

第5步執行成功後會有如下信息提示
至此我們已經完成了boost庫的安裝,下面需要配置一下VS2013了。新建一個VS2013控制台應用程序(工程名為boostest),添加如下代碼
#include "stdafx.h"
#include <boost/lexical_cast.hpp>
#include <iostream>
using namespace std;
int main()
{
using boost::lexical_cast;
int a = lexical_cast<int>("123");
double b = lexical_cast<double>("123.0123456789");
string s0 = lexical_cast<string>(a);
string s1 = lexical_cast<string>(b);
cout << "number: " << a << " " << b << endl;
cout << "string: " << s0 << " " << s1 << endl;
int c = 0;
try{
c = lexical_cast<int>("abcd");
}
catch (boost::bad_lexical_cast& e){
cout << e.what() << endl;
}
return 0;
}
添加boostest工程的包含目錄和庫目錄
包含目錄添加 G:\boost_1_55_0
庫目錄添加 G:\boost_1_55_0\stage\lib

進入代碼窗口編譯並成功運行說明BOOST庫確實已經配置成功,可以放心使用。

閱讀全文

與boost命令相關的資料

熱點內容
上網行為linux 瀏覽:346
解壓對身體的好處 瀏覽:65
php服務端框架 瀏覽:447
gitlabpdf 瀏覽:605
大專程序員面試公司 瀏覽:948
iphone相片不能新建文件夾 瀏覽:444
底部加密封條 瀏覽:492
linux變數字元串 瀏覽:430
蘋果解壓視頻在哪裡找 瀏覽:965
中國程序員發現最大程序漏洞 瀏覽:776
圖像數據加密解密 瀏覽:190
pdf金 瀏覽:512
湖北拼團商城源碼 瀏覽:200
為什麼說伺服器沒有響應 瀏覽:973
linux怎麼搭web伺服器 瀏覽:255
房產證加密收費嗎 瀏覽:156
slam演算法處理數據 瀏覽:270
如何判斷伺服器ip地址和版本號 瀏覽:967
python獲取html內容 瀏覽:773
北歐大神程序員 瀏覽:207