Boost编译

下载源码

Boost C++ Libraries

image-20210823011532225

image-20210823011744796

安装Python环境

Download Python | Python.org

image-20210823012732452

编译

进入解压目录

  • Windows 执行 bootstrap.bat,vc14对应VS2015

    bootstrap.bat vc14
    
  • Linux 执行 bootstrap.sh

    ./bootstrap.sh
    

开始编译

参数解释:

(1) toolset: 表示编译器工具, VS2015对应msvc-14.0

(2) architecture:表示架构,也就是你的CPU架构,x86,x64

(3) instruction-set:表示指令集,依然是8086指令集

(4) address-model:表示地址长度,为32位或64位。

(5) link:表示生成动态/静态链接库,动态链接库是shared,静态链接库是static

(6) variant:表示生成的debug或者release版本。

(7) threading:表示单/多线程编译,一般我们的程序都会用到多线程,所以选择了multi

(8) runtime-link:表示动态/静态链接C/C++运行时库(C/C++Runtime)

(9) without/with: 表示不需要编译/需要编译哪些库,一些自己不用的库可以无需编译

(10) stage/install: stage表示只生成库文件(DLL和Lib),install还会生成包含头文件的include目录.

(11) stagedir/prefix:stage时使用stagedir,install时使用prefix,表示编译生成文件的路径。

(12) build-dir:编译生成的中间文件的路径。

  • Windows 执行 bjam,msvc-14.0 对应 VS2015,link选择静态库还是动态库,动态库改为shared,address-model表示32位还是64位(默认32)

    b2 --build-type=complete toolset=msvc-14.0 threading=multi link=static address-model=64
    
  • Linux 执行 b2

    ./b2 link=static runtime-link=static address-model=64