Compile and use C ++ Boost libraries

https://www.jianshu.com/p/de1fda741beb

 

Compile


Generate their own use boost the build tools bjam.exe

After decompression, using Visual Studio compiler. First, open the "Developer Command", cd to the boost unpacked root directory:
cd X:\boost_X_XX_X

Execution bootstrap.bat, will generate b2.exe, bjam.exe, project-config.jam, bootstrap.log four files in the root directory of boost. Which, b2.exe, bjam.exe two exe effect is the same, bjam.exe the old version, b2 is an upgraded version of bjam.

Using the bjam (or b2) to compile boost

bjam command parameters analyzed
the role of example in the following order to analyze various parameters
bjam stage --toolset=msvc-14.0 --without-python --stagedir="X:\boost\vc14" link=static runtime-link=shared runtime-link=static threading=multi debug release

  1. Stage / install:
    Stage represents only generate libraries (dll and lib), install also generates include directory contains header files. Recommended stage, because the install directory generated by this include that boost actual installation directory boost after unzip the package (X: \ boost_X_XX_X \ boost, just a few more non-hpp files are smaller than the include directory), so you can directly use , and different IDE can use the same set of header files, saving compilation time, but also save hard disk space.

  2. toolset:
    Specifies the compiler, such as optional borland, gcc, msvc (VC6) , msvc-12.0 (VS2013), msvc-14.0 (VS2015) the like.

  3. without / with:
    choose not to compile / compiler which libraries. Because python, mpi library, etc. I have no need, therefore to exclude. There wave, graph, math, regex, test, program_options, serialization, signals these libraries to compile the static lib are very large, so do not need can be without. This can be selected according to their needs, the default is all compiled. Note, however, if you choose to compile python, then, is the need python language support, you can go to the python official home page to download and install.
    Command to view the boost library is included bjam --show-libraries.

  4. stagedir / prefix:
    Use stagedir stage when, during the install using the prefix, represents compiled file path. Recommended to different IDE specify a different directory, such as that corresponding to VS2015

X:\boost_X_XX_X\vc14

If the install parameters, then it will generate a header file directory, vc14 correspondence is

X:\boost_X_XX_X\boost\bin\vc14\include\boost_X_XX_X\boost

  1. build-dir:
    compiler intermediate file generated path. I am here this is useless to default in the root directory: lower (X \ boost_X_XX_X \ boost), a directory named bin.v2, etc. After compilation can delete all the catalog (useless), so do not need to set .

  2. link:
    build a dynamic link library / static link library. Generate dynamic link library need to use shared ways to generate static link libraries need to use static way. General boost libraries may have been compiled in a static way, because the final release of the program with a boost dll feeling would be more cumbersome.

  3. runtime-link:
    dynamic / static linking C / C ++ runtime library. Static and also has shared in two ways, so that a total runtime-link and the link can generate four kinds of combinations, each one can be selected according to their needs compiled.

  4. threading:
    single / multi-threaded compilation. They are generally multi-threaded program, of course, you want to specify a multi way; if you need to write single-threaded programs, you also need to compile a single-threaded library, you can use the single way.

  5. debug / release:
    Compile debug / release version. Debug version of the program are generally corresponds debug version of the library, so the two are compiled.

Configuration


Include path to include the header file: X: \ boost_X_XX_X
link library file that contains the path of: X: \ boost_X_XX_X \ bin \ vc14 \ lib

  1. Can be set only for the current project:
    select the current project-> Properties-> Configuration Properties-> C / C ++ -> General: Additional Include Directories: Set X: \ boost_X_XX_X
    selected current project-> Properties-> Configuration Properties-> Linker -> General: Additional LibraryDirectories: set X: \ boost_X_XX_X \ bin \ vc14 \ lib

  2. Can be set only for the current Solution:
    Select current Project-> Properties-> the Configuration Properties-> VC ++ Directories:
    the Include Directories: Set the X-: \ boost_X_XX_X
    LibraryDirectories: Set X: \ boost_X_XX_X \ bin \ vc14 \ lib

  3. Can be set to VC ++ environment (all Solution VC ++ created under the current user) under the current OS user
    under a project already open, switch to the Property Manager tab, and then expand the properties to configure the current project, open Microsoft.Cpp .Win32.User
    select Properties- the Common> VC ++ Directories:
    the Include Directories: set the X-: \ boost_X_XX_X
    LibraryDirectories: set X: \ boost_X_XX_X \ bin \ vc14 \ lib
    only works under Win32 compiler options, x64 compiler options need to set additional configure the properties sheet x64.

4. VC ++ may be set to the OS environment for all users
can edit Microsoft.Cpp.Default.props, Microsoft.Cpp.props. Not presented here.

References




Author: elivera
link: https: //www.jianshu.com/p/de1fda741beb
Source: Jane book
Jane book copyright reserved by the authors, are reproduced in any form, please contact the author to obtain authorization and indicate the source.

Guess you like

Origin www.cnblogs.com/mingzhang/p/11349808.html