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

熱點內容
華為手機代碼編程教學入門 瀏覽:762
和彩雲沒會員怎樣解壓 瀏覽:634
androidimageview保存 瀏覽:387
新買店鋪什麼伺服器 瀏覽:883
文件夾能直接刻錄嗎 瀏覽:493
androidxmpp刪除好友 瀏覽:969
javac哪個前景好 瀏覽:426
中華英才網app為什麼不能搜索了 瀏覽:660
伺服器域名是什麼意思 瀏覽:52
Linux導出mysql命令 瀏覽:159
無詐建鄴是什麼app 瀏覽:228
python中的雙色球 瀏覽:166
python解釋器里如何換行 瀏覽:410
python編寫格式 瀏覽:574
用python做出來的軟體 瀏覽:469
伺服器指示燈代表什麼 瀏覽:702
做一個單片機銷售需要知識 瀏覽:777
怎樣去連接加密wifi 瀏覽:682
有什麼app自帶拍攝模板的 瀏覽:435
登錄相親網為什麼要下載app呢 瀏覽:545