编译并使用boost库(win7+boost1.60+vs2013)
生活随笔
收集整理的這篇文章主要介紹了
编译并使用boost库(win7+boost1.60+vs2013)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
下載boost庫
bjam?stage?--toolset=msvc-12.0?--without-graph?--without-graph_parallel?--stagedir="D:\boost\boost_1_60_0\bin\vc12"?link=static?runtime-link=shared?runtime-link=static?threading=multi?debug?release??
bjam stage --toolset=msvc-12.0 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_60_0\bin\vc12" link=static runtime-link=shared runtime-link=static threading=multi debug release
#include?"boost/thread.hpp"?? #include?"iostream"?? using?namespace?std;?? ?? ?? void?mythread()?? {?? ????cout?<<?"?hello,thread!?"?<<?endl;?? }?? ?? ?? int?_tmain(int?argc,?_TCHAR*?argv[])?? {?? ????boost::function<void()>?f(mythread);?? ????boost::thread?t(f);?? ????t.join();?? ????cout?<<?"?thread?is?over!?"?<<?endl;?? ?? ?? ????return?0;?? }??
#include "boost/thread.hpp"
#include "iostream"
using namespace std;void mythread()
{cout << " hello,thread! " << endl;
}int _tmain(int argc, _TCHAR* argv[])
{boost::function<void()> f(mythread);boost::thread t(f);t.join();cout << " thread is over! " << endl;return 0;
}
從http://www.boost.org上下載到目前最新的boost庫,快速傳送門:boost_1_60_0.zip
?
得到源代碼之后,使用vs2013的cl.exe編譯
進入到源代碼目錄中
建立編譯工具bjam.exe----需要執(zhí)行bootstrap.bat
指定編譯命令
?
指定msvc版本12.0對應的是vs2013,--stagedir是指定編譯后存放的目錄
[cpp] view plaincopy print?稍微等一會,庫就編譯好了……
開始使用boost
首先需要設定文件包含目錄:
我的boost庫解壓在D盤下
設定庫目錄:
然后建立我們的第一個boost項目,代碼如下:
[cpp] view plaincopy print?這是輸出
新人創(chuàng)作打卡挑戰(zhàn)賽發(fā)博客就能抽獎!定制產品紅包拿不停!總結
以上是生活随笔為你收集整理的编译并使用boost库(win7+boost1.60+vs2013)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iOS9 HTTPS
- 下一篇: POJ2817 WordStack(状压