1 下載下傳 Boost 源代碼
- 根據 Visual Studio 版本來選擇 Boost 版本。在 Visual Studio 中點選幫助>關于Microsoft Visual Studio 檢視版本。VS2017是15.2。
- 決定是使用 32-bit 還是 64-bit 的 Boost 庫。
- 去下載下傳網址下載下傳對應的版本。msvc-15.2 對應的版本還沒有釋出,我使用的是 boost_1_64_0-msvc-14.1-64.exe 這個版本。
- 下載下傳完成後進行安裝,注意** {Boost 安裝目錄} **
2 編譯 Boost 源代碼
- 打開 Developer Command Prompt for VS 2017。
- 打開 Developer Command Prompt 後,輸入cd {Boost 安裝目錄}
- 輸入bootstrap指令,之後輸入b2。
- b2指令完成後,螢幕會顯示{compiler include paths}和{linker library paths}。
3 在 Visual Studio 中添加 Boost
- 使用 Visual Studio 建立一個 C++ 項目,右鍵項目,點選屬性。
- 點選 C/C++ > 所有選項。
- 在附加包含目錄出添加 {compiler include paths}。
- 在連結器 > 附加庫目錄處添加 {linker library paths}。
- 點選确定,在項目包含 Boost 庫來測試是否成功,在源檔案頂部添加 #include <boost/foreach.hpp>
- 如果編譯成功,說明 Boost 安裝成功了!
轉載于:https://www.cnblogs.com/49er/p/7193979.html