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 安裝成功了!