首先下載得到boost的最新版(目前最新版是1.63)
下載地址:
打開vs的32位命令行工具
進入到boost源代碼文件夾中
進入到boost源代碼文件夾中
運行bootstrap.bat
執行如下操作,對boost進行編譯
(msvc版本14.0對應的是vs2015,--stagedir是指定編譯后存放的目錄,文章附錄有vs版本對應編號)
bjam stage --toolset=msvc-14.0 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14" link=static runtime-link=shared runtime-link=static threading=multi debug release
進入到boost源代碼文件夾中
運行bootstrap.bat
執行如下操作,對boost進行編譯
(msvc版本14.0對應的是vs2015,--stagedir是指定編譯后存放的目錄)
bjam stage --toolset=msvc-14.0 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="D:\boost\boost_1_63_0\bin\vc14-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release
這樣得到的是就是64位的boot庫
設置測試的程序為64位
設置附加的包含路徑(下載之后解壓的boost文件夾):
設定庫路徑:
然后建立第一個boost項目,代碼如下:
-
-
-
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;
-
}
得到輸出
附錄
附上版本對應編號
-
VC6
-
VC7(2003)
-
VC8(2005)
-
VC9(2008)
-
VC10(2010)
-
VC11(2012)
-
VC12(2013)
-
https://blog.csdn.net/zengraoli/article/details/70187556
附帶一個boost使用線程池的例子
下面文章是vs2015編譯, 將140換為141,則可以編譯給vs2017用.
編譯64位:
先打開vs2017 64位環境的cmd環境, 進入boost源目錄, 運行bootstrap.bat,然后運行下面編譯命令,
stagedir用來指定庫存放的位置
bjam stage --toolset=msvc-14.1 architecture=x86 address-model=64 --without-graph --without-graph_parallel --stagedir="c:\boost\boost_1_64_0\bin\vc141-x64" link=static runtime-link=shared runtime-link=static threading=multi debug release 編譯32位:
先打開vs2017 x86環境的cmd環境, 進入boost源目錄, 運行bootstrap.bat,然后運行下面編譯命令,
bjam stage --toolset=msvc-14.1 --without-graph --without-graph_parallel --stagedir="c:\boost\boost_1_64_0\bin\vc141-x86" link=static runtime-link=shared runtime-link=static threading=multi debug release 要等好一會兒的.
https://blog.csdn.net/rocklee/article/details/72885587
