visual studio编译boost1.73.0静态库32位和64位

本文详细介绍如何使用Visual Studio 2015编译Boost库,包括32位和64位的编译命令,以及编译参数的详细解释。同时,文章还解析了编译出的Boost库文件名构成规则,帮助理解不同配置下库文件的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用vs2015编译32位

REM 使用vs2015,如果vs2019将下面的vc14替换为vc142(特殊:--toolset=msvc-14.2
CALL bootstrap vc14
CALL b2 stage --build-dir=build/vc14_32 --toolset=msvc-14.0 address-model=32 --without-python --stagedir=vc14/32 link=static runtime-link=shared runtime-link=static threading=multi debug release -j 12

使用vs2015编译64位

REM vs2015编译64位 如果vs2019下面的vc14替换为vc142(特殊:--toolset=msvc-14.2)
CALL bootstrap vc14
CALL b2 stage --build-dir=build/vc14_64 --toolset=msvc-14.0 address-model=64 --without-python --stagedir=vc14/64 link=static runtime-link=shared runtime-link=static threading=multi debug release -j 12

编译出的头文件:

$(BOOST_SOURCE_DIR)/boost

在设置工程头文件路径设置为$(BOOST_SOURCE_DIR)

这样在C++代码中可以使用

 #include <boost/...>

编译出来的库简要说明(库在$(BOOST_SOURCE_DIR)/vc14下的32位和64位文件夹中)

b2.exe 参数解释:

 

  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.

  --exec-prefix=<EPREFIX> Install architecture dependent files here.
                          Default; <PREFIX>

  --libdir=<DIR>          Install library files here.
                          Default; <EPREFIX>/lib

  --includedir=<HDRDIR>   Install header files here.
                          Default; <PREFIX>/include

  stage                   Build and install only compiled library files to the
  =====                   stage directory.

  --stagedir=<STAGEDIR>   Install library files here
                          Default; ./stage

Other Options:

  --build-type=<type>     Build the specified pre-defined set of variations of
                          the libraries. Note, that which variants get built
                          depends on what each library supports.

                              -- minimal -- (default) Builds a minimal set of
                              variants. On Windows, these are static
                              multithreaded libraries in debug and release
                              modes, using shared runtime. On Linux, these are
                              static and shared multithreaded libraries in
                              release mode.

                              -- complete -- Build all possible variations.

  --build-dir=DIR         Build in this location instead of building within
                          the distribution tree. Recommended!

  --show-libraries        Display the list of Boost libraries that require
                          build and installation steps, and then exit.

  --layout=<layout>       Determine whether to choose library names and header
                          locations such that multiple versions of Boost or
                          multiple compilers can be used on the same system.

                              -- versioned -- Names of boost binaries include
                              the Boost version number, name and version of
                              the compiler and encoded build properties. Boost
                              headers are installed in a subdirectory of
                              <HDRDIR> whose name contains the Boost version
                              number.

                              -- tagged -- Names of boost binaries include the
                              encoded build properties such as variant and
                              threading, but do not including compiler name
                              and version, or Boost version. This option is
                              useful if you build several variants of Boost,
                              using the same compiler.

                              -- system -- Binaries names do not include the
                              Boost version number or the name and version
                              number of the compiler. Boost headers are
                              installed directly into <HDRDIR>. This option is
                              intended for system integrators building
                              distribution packages.

                          The default value is 'versioned' on Windows, and
                          'system' on Unix.

  --buildid=ID            Add the specified ID to the name of built libraries.
                          The default is to not add anything.

  --python-buildid=ID     Add the specified ID to the name of built libraries
                          that depend on Python. The default is to not add
                          anything. This ID is added in addition to --buildid.

  --help                  This message.

  --with-<library>        Build and install the specified <library>. If this
                          option is used, only libraries specified using this
                          option will be built.

  --without-<library>     Do not build, stage, or install the specified
                          <library>. By default, all libraries are built.

Properties:

  toolset=toolset         Indicate the toolset to build with.

  variant=debug|release   Select the build variant

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

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

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

编译得到 库名字的明(来自官网https://www.boost.org/doc/libs/1_73_0/more/getting_started/unix-variants.html#library-naming):

In order to choose the right binary for your build configuration you need to know how Boost binaries are named. Each library filename is composed of a common sequence of elements that describe how it was built. For example,libboost_regex-vc71-mt-d-x86-1_34.lib can be broken down into the following elements:

lib

Prefix: except on Microsoft Windows, every Boost library name begins with this string. On Windows, only ordinary static libraries use the lib prefix; import libraries and DLLs do not.4

boost_regex

Library name: all boost library filenames begin with boost_.

-vc71

Toolset tag: identifies the toolset and version used to build the binary.

-mt

Threading tag: indicates that the library was built with multithreading support enabled. Libraries built without multithreading support can be identified by the absence of -mt.

-d

ABI tag: encodes details that affect the library's interoperability with other compiled code. For each such feature, a single letter is added to the tag:

KeyUse this library when:Boost.Build option
slinking statically to the C++ standard library and compiler runtime support libraries.runtime-link=static
gusing debug versions of the standard and runtime support libraries.runtime-debugging=on
yusing a special debug build of Python.python-debugging=on
dbuilding a debug version of your code.5variant=debug
pusing the STLPort standard library rather than the default one supplied with your compiler.stdlib=stlport

For example, if you build a debug version of your code for use with debug versions of the static runtime library and the STLPort standard library, the tag would be: -sgdp. If none of the above apply, the ABI tag is ommitted.

-x86

Architecture and address model tag: in the first letter, encodes the architecture as follows:

KeyArchitectureBoost.Build option
xx86-32, x86-64architecture=x86
aARMarchitecture=arm
iIA-64architecture=ia64
sSparcarchitecture=sparc
mMIPS/SGIarchitecture=mips*
pRS/6000 & PowerPCarchitecture=power

The two digits following the letter encode the address model as follows:

KeyAddress modelBoost.Build option
3232 bitaddress-model=32
6464 bitaddress-model=64

-1_34

Version tag: the full Boost release number, with periods replaced by underscores. For example, version 1.31.1 would be tagged as "-1_31_1".

.lib

Extension: determined according to the operating system's usual convention. On most unix-style platforms the extensions are .a and .so for static libraries (archives) and shared libraries, respectively. On Windows, .dll indicates a shared library and .lib indicates a static or import library. Where supported by toolsets on unix variants, a full version extension is added (e.g. ".so.1.34") and a symbolic link to the library file, named without the trailing version number, will also be created.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值