boost 設置與編譯 (1.56.0)

出處:http://blog.xuite.net/kamory0931/fightdreamer/240610144-boost+%E8%A8%AD%E7%BD%AE%E8%88%87%E7%B7%A8%E8%AD%AF+(1.56.0)

[環境]
Windows 8.1 64-bit
Visual Studio 2010
Microsoft DirectX SDK (June 2010)
boost Version 1.56.0
[準備boost檔案]
下載網址
http://www.boost.org/
放入資料夾

解壓縮需要一段時間
488MB

[使用VS編譯資料庫]
打開VS的命令提示字元
Visual Studio Command Prompt (2010)
依序輸入指令
D:
cd D:boostboost_1_56
bootstrap
編譯指令
bjam stage –toolset=msvc-10.0 –build-type=complete –stagedir=”D:boostboost_1_56binvc10″ link=static runtime-link=shared threading=multi debug release

因為會編很久,如果沒事可以看參考資料裡的編譯指令相關說明。
[設定VS函式庫連結]
D:boostboost_1_56
D:boostboost_1_56binvc10lib

[測試程式1]

01.#include <boost/numeric/ublas/vector.hpp>
02.#include <boost/numeric/ublas/matrix.hpp>
03.#include <boost/numeric/ublas/io.hpp>
04.#include <iostream>
05. 
06.using namespace boost::numeric::ublas;
07. 
08.int main ()
09.{
10.vector<double> x (2);
11.x(0) = 1; x(1) = 2;
12. 
13.matrix<double> A(2,2);
14.A(0,0) = 0; A(0,1) = 1;
15.A(1,0) = 2; A(1,1) = 3;
16. 
17.vector<double> y = prod(A, x);
18. 
19.std::cout << y << std::endl;
20. 
21.system(“pause”);
22.return 0;
23.}
[測試程式2]
01.#include <boost/scoped_ptr.hpp>
02.#include <string>
03.#include <iostream>
04. 
05.int main()
06.{
07.boost::scoped_ptr<std::string> p(new std::string(“Use scoped_ptr often.”));
08.if (p)
09.{
10.std::cout << *p << std::endl;
11.}
12. 
13.size_t i = p->size();
14.std::cout << i << std::endl;
15. 
16.*p = “Acts just like a pointer”;
17. 
18.system(“pause”);
19.return 0;
20.}

[參考資料]
http://www.perfect-is-shit.com/windows-boost-install-config.html
http://blog.sina.com.cn/s/blog_6e0693f70100txlg.html
http://www.vipaq.com/Article/View/blog/365.html
http://blog.csdn.net/misskissc/article/details/9793645
http://www.cnblogs.com/wondering/archive/2009/05/21/boost_setup.html

未經允許不得轉載:GoMCU » boost 設置與編譯 (1.56.0)