Build Boost C++ libraries for x32/x64 VC++ compilers on Windows

Boost is a set of libraries for the C++ programming language that provide support for tasks and structures such as linear algebra, pseudorandom number generation, multithreading, image processing, regular expressions, and unit testing. Steps to build Boost for x32/x64 VC++ compilers on Windows are as follows:

  1. Download Boost and extract it to PC (assume C:\Libs\boost_1_47_0).
  2. Double click to run bootstrap.bat in Boost's root folder, which will generate bjam.exe (and b2.exe …) in the same folder.
  3. Run VC++.
  4. VC++ > Tools > Visual Studio Command Prompt.
  5. In the command window, first change working folder to C:\Libs\boost_1_47_0 and type the following command (Note: it will take a long time to finish, which is depended on your system, 20min for me.):

    bjam --build-type=complete toolset=msvc-10.0 threading=multi link=static address-model=64

  6. Setup VC++. Two steps need to be done.
    • Add C:\Libs\boost_1_47_0 to project Include files.
    • Add C:\Libs\boost_1_47_0\stage\lib to project Library files.

Remarks:

  • The above step will build static Boost libraries for x64 VC++. Options (colored command in step 5) can be modified in step 5 to build it for other versions' VC++, see the following table for details.

Command       |  Options   | Meanning
--------------|------------|----------------------------------
              |  msvc-6.5  | Visual Studio 6.0, Service Pack 5
              |  msvc-8.0  | Visual Studio 2005
toolset       |  msvc-9.0  | Visual Studio 2008
              |  msvc-10.0 | Visual Studio 2010
              |  msvc-11.0 | Visual Studio 2012
--------------|------------|----------------------------------
link          |  static    | static libraries
              |  shared    | shared libraries
--------------|------------|----------------------------------
address-model |  32        | x32 VC++ compilers
              |  64        | x64 VC++ compilers

////////////////////////////////////////////////////////////////////////////

编译 64 位 boost 库

vc 和 intel 编译器

    编译 64 位 boost 库的方法:

        bjam.exe --toolset=msvc address-model=64 --build-type=complete

        bjam.exe --toolset=intel address-model=64 --build-type=complete

    编译 32 位 boost 库的方法:

        bjam.exe --toolset=msvc --build-type=complete

        bjam.exe --toolset=intel --build-type=complete

一个参数开关的差别,然后就慢慢喝茶等待吧。

编译出来的库文件名称都是一样的,小心不要把 32 位和 64 位的文件互相覆盖了

////////////////////////////////////////////////////////////////////////////

bjam stage --toolset=msvc-11.0 --without-mpi --without-wave --without-graph --without-math --without-serialization --stagedir="D:\dev_proj\boost_1_54_0\自定义输出" link=shared runtime-link=shared threading=multi debug release

////////////////////////////////////////////////////////////////////////////

.\b2 --build-type=complete toolset=vc11

你可能感兴趣的:(Build Boost C++ libraries for x32/x64 VC++ compilers on Windows)