導航:首頁 > 程序命令 > 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命令相關的資料

熱點內容
如何下載老友麻將app 瀏覽:443
java路徑參數 瀏覽:590
php命名空間使用 瀏覽:296
app的競爭力如何寫 瀏覽:585
linux刪除swp 瀏覽:588
pdfxchange40 瀏覽:75
車牌號碼是哪個app 瀏覽:48
文件夾如何添加圓點 瀏覽:729
如何建立主索引命令 瀏覽:599
mac電腦怎麼打開終端命令 瀏覽:741
androidvpn待機不斷 瀏覽:756
硬碟的文件夾如何設置密碼 瀏覽:384
plc定位編程 瀏覽:47
mac命令添加用戶 瀏覽:815
android時間widget 瀏覽:393
qd128h壓縮機參數 瀏覽:287
用單片機測車距 瀏覽:394
去哪裡找加密的便簽 瀏覽:19
武漢訂酒店旅館哪個app平台好 瀏覽:114
c語言在線編譯器位元組流 瀏覽:317