很不錯的博客一定得看
http://my.csdn.net/caimouse
1、下載boost庫
從http://www.boost.org上下載到目前最新的boost庫,快速傳送門:boost_1_53_0.zip,當然你也可以從http://sourceforge.net/projects/boost/files/boost-jam/這里得到源代碼,快速傳送門:boost_1_53_0.zip(98.1 MB)
我使用了后者
2、得到源代碼之后,使用vs2012的cl.exe編譯

進入到源代碼目錄中
3、建立編譯工具bjam.exe----需要執行bootstrap.bat

4、指定編譯命令
指定msvc版本11.0對應的是vs2012,--stagedir是指定編譯后存放的目錄
bjam stage --toolset=msvc-11.0 --without-graph --without-graph_parallel --without-math --without-mpi --without-python --without-serialization --without-wave --stagedir="F:\boost\boost_1_53_0\bin\vc11" link=static runtime-link=shared runtime-link=static threading=multi debug release
稍微等一會,庫就編譯好了……
5、開始使用boost
首先需要設定文件包含目錄:
我的boost庫解壓在F盤下

設定庫目錄:
“F:\boost\boost_1_53_0\”是我編譯的出來lib的目錄
然后建立我們的第一個boost項目,代碼如下:
- #include "stdafx.h"
- #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;
- }
6.這是輸出:
