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编译还是比较简单的,或者说官方提供了比较友好的编译方式,为广大的使用者减少负担,点赞。

猜你喜欢

转载自www.cnblogs.com/qinwanlin/p/boost.html
今日推荐