boost 1.67編譯VS2017版本


最近想系統學習並使用一下boost的asio異步網絡庫,所以需要編譯boost庫使用,下面簡單介紹如何編譯。

 

編譯環境

boost1.67版本,windows 10,VS2017

 

下載boost

建議到官網去下載,目前最新的是1.67版本,鏈接:https://dl.bintray.com/boostorg/release/1.67.0/source/,會提供很多壓縮方式的壓縮包,我選擇了zip版本的。

 

解壓

把壓縮包boost_1_67_0.zip解壓到當前目錄,得到boost_1_67_0目錄。

 

編譯

直接進入boost_1_67_0目錄,雙擊運行腳本bootstrap.bat,編譯boost編譯引擎(Building Boost.Build engine)。等待幾分鍾,就會編譯出b2.exe和bjam.exe,這小步驟就表示成功了。

新建一個build_vs2017.bat腳本文件,輸入如下內容:

@ECHO OFF

ECHO Building Boost lib, vs2017

bjam.exe install --prefix="boost_1_67_vs2017" --toolset=msvc-14.1  link=static runtime-link=shared threading=multi debug release

 

執行程序bjam.exe,后面的參數可執行bjam.exe --help來了解具體內容

install                        Install headers and compiled library files to the configured locations (below).

--prefix=<PREFIX>   Install architecture independent files here.Default; C:\Boost on Win32; Default; /usr/local on Unix. Linux, etc.

toolset=toolset         Indicate the toolset to build with.

link=static|shared     Whether to build static or shared libraries

runtime-link=static|shared Whether to link to static or shared C and C++ runtime.

threading=single|multi  Whether to build single or multithreaded binaries

 

等待10多分鍾,即可看到當前目錄下有一個目錄boost_1_67_vs2017,里面則是編譯出來的庫,其中還包括頭文件。里面的庫比較多,為了方便引用具體的庫,可參考庫的命名規范:

http://www.cppblog.com/Robertxiao/archive/2013/01/06/197022.html

 

總結

總體來說,boost編譯還是比較簡單的,或者說官方提供了比較友好的編譯方式,為廣大的使用者減少負擔,點贊。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM