Vs2008 compile boost
[1. Introduction to boost libraries]
The boost library is a C ++ library that has been tested, transplanted, and provided with source code. As a backup for the standard library, it is one of the engines of the C ++ standardization process. The boost library is initiated by members of the C ++ Standards Committee Working Group. Some of the content is expected to become the content of the next-generation C ++ standard library. The C ++ community has a huge impact, with nearly 2000 members. The boost Library provides us with the latest, coolest, and most practical technologies. It is an uncompromising standard library.
There are several well-known boost libraries:
(1) RegEx, regular expression library;
(2) spirit, ll parser framework, and express ebnf directly using C ++ code;
(3) graph, graph components and algorithms;
(4) Lambda defines short and anonymous function objects in the called place, which is a very practical functional function;
(5) concept check: Check concept in generic programming;
(6) MPL, a template-based meta-programming framework;
(7) thread, a portable C ++ multi-thread library;
(8) Python: maps C ++ classes and functions to Python;
(9) pool, memory pool management;
(10) smart_ptr: smart pointer.
[2. Boost library compilation]
[Preparations for setp1 ]:
(1) download boost from the official website:
Http://www.boost.org/
(2) install vs2008 ide
[Setp2 compilation boost]
1. Open the Visual Studio 2008 Command Prompt window
2. Enter D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_44_0 \ boost_44_0 \ tools \ jam \ SRC
3. Execute build. bat on D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_000044_0 \ boost_000044_0
\ Tools \ jam \ SRC \ bin. ntx86 generates the bjam.exe file.
4. Copy the bjam.exe file to D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_000044_0 \ boost_000044_0.
6. Go to the D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_44_0 \ boost_44_0 directory.
7.run the following command to compile bjam.exe:
(1) compile all boost dynamic libraries (release | Debug), including header files and library files
Bjam -- toolset = msvc-9.0 -- prefix = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_000044_0 \ output -- without-Python -- Build-type = complete link = shared threading = multi install
(2) Compile only the release version RegEx dynamic library, including header files and library files.
Bjam -- toolset = msvc-9.0 -- prefix = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_000044_0 \ output1 -- With-RegEx link = shared threading = multi variant = release runtime-link = shared install
(3) Compile only the release version RegEx dynamic library, including the Library File
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output2
-- With-RegEx link = shared threading = multi variant = release runtime-link = shared stage
[Note]: The boost source code path should be in full English, and should not contain spaces, special characters, Chinese characters, etc.
It takes about 30 minutes to compile (based on the performance of the PC). The directory will be generated in the specified directory:
D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output to generate the corresponding library file and header file.
8. Set the development environment
Open vs2008 to create a project and configure Project Properties
Set the include file directory F: \ develop \ boostlibanddll \ include \ boost-1_37 \ boost
Set the directory of the referenced file: F: \ develop \ boostlibanddll \ Lib
After that, you can use it.
[3. Introduce bjam usage]
Usage:
Bjam [Options] [properties] [install | stage]
Install install headers and compiled library files to
======= Configured locations (below ).
Generate all header files under the directory specified by "-- prefix ="
(All files in the boost folder under Boost source code) and specified library files
-- 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 =
Default; <prefix>/include
Stage build and install only compiled library files
====== To the stage directory.
Generate the specified library file under the directory specified by "-- stagedir ="
-- 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 the single
"Release" version of the Libraries. This
Release corresponds to specifying:
"Release <threading> multi <link> shared
<Link> static <runtime-link> shared "as
Build variant to build.
Complete-attempts to build all possible
Variations.
-- Build-Dir = dir build in this location instead of building
Within the distribution tree. Recommended!
-- Show-libraries displays the list of boost libraries that require
Build and installation steps, then exit.
-- Layout = <layout> determines 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 (default)-names of boost
Binaries include the boost version
Number and the name and version of
Compiler. Boost headers are installed
In a subdirectory of
Name contains the boost version number.
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
Intended for system integrators who
Are building distribution packages.
-- Buildid = ID adds the specified ID to the name of built
Libraries. The default is to not add anything.
-- 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 indicates the toolset to build.
Msvc-6.0: vc6.0
Msvc-7.0: vs2003
Msvc-8.0: vs2005
Msvc-9.0: vs2008
Msvc-10.0: vs2010
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.
Determines whether the database is static or dynamically linked to the C/C ++ standard library.
Bjam options and parameter descriptions
-- Build-Dir = <builddir>
The compiled temporary file will be placed in builddir (you can delete it after compilation)
-- Stagedir = <stagedir>
Path for storing compiled library files. The default path is stage.
-- Build-type = complete
Compile all versions. Otherwise, only a small part of the version will be compiled (equivalent:
Variant = release, threading = multi;
Link = shared | static; runtime-link = shared)
Variant = debug | release
Determine the version to compile (debug or release)
Link = static | shared
Decide whether to use static or dynamic Databases
Threading = single | multi
Decide whether to use a single thread or multi-thread Library
Runtime-link = static | shared
Determines whether the database is static or dynamically linked to the C/C ++ standard library.
-- With-<library>
Compile only the specified database, for example, input -- With-RegEx to compile only the RegEx database.
-- Show-libraries
Display the name of the library to be compiled
[IV. Analysis of bjam file generation]
(1) generate the release version, multithreading, and dynamically link the RegEx dynamic library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output2
-- With-RegEx link = shared threading = multi variant = release runtime-link = shared stage
-- Output: boost_regex-vc90-mt.lib
Boost_regex-vc90-mt-1_44.lib
Boost_regex-vc90-mt-1_44.dll
(2) generate the release version, multithreading, and static link to the RegEx dynamic library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output2
-- With-RegEx link = shared threading = multi variant = release runtime-link = static stage
-- Output: This configuration is not available.
(3) generate the release version, multithreading, and dynamically link the RegEx static library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output2
-- With-RegEx link = static threading = multi variant = release runtime-link = shared stage
-- Output: libboost_regex-vc90-mt-s.lib
Libboost_regex-vc90-mt-1_44.lib
(4) generate the release version, multithreading, and static link to the RegEx static library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output3
-- With-RegEx link = static threading = multi variant = release runtime-link = static stage
-- Output: libboost_regex-vc90-mt-s.lib
Libboost_regex-vc90-mt-s-1_44.lib
Bytes --------------------------------------------------------------------------------------------------------------------
(1) generate the debug version, multithreading, and dynamically link the RegEx static library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output4
-- With-RegEx link = static threading = multi variant = debug runtime-link = shared stage
-- Output: libboost_regex-vc90-mt-gd.lib
Libboost_regex-vc90-mt-gd-1_44.lib
(2) generate the debug version, multithreading, and static link to the RegEx static library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output5
-- With-RegEx link = static threading = multi variant = debug runtime-link = static stage
-- Output: libboost_regex-vc90-mt-sgd.lib
Libboost_regex-vc90-mt-sgd-1_44.lib
(3) generate the debug version, multi-thread, and dynamically link the RegEx dynamic library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output5
-- With-RegEx link = shared threading = multi variant = debug runtime-link = shared stage
-Output: boost_regex-vc90-mt-gd.lib
Boost_regex-vc90-mt-gd-1_44.lib
Boost_regex-vc90-mt-gd-1_44.dll
(4) generate the debug version, multithreading, and static link to the RegEx dynamic library of the C ++ standard library
Bjam -- toolset = msvc-9.0
-- Stagedir = D: \ 05_computer \ 04_3rdpatry \ 02boost \ boost_1_44_0 \ output5
-- With-RegEx link = shared threading = multi variant = debug runtime-link = static stage
-- Output: This configuration is not available.
[Summary ]:
(1) After compilation, bjam will generate a pair of identical import/export files or static library files (as follows ),
The only difference is that the two file names are followed by the boost version information, in order to let the user know the boost version information.
Boost_regex-vc90-xxxxx.lib
Boost_regex-vc90-xxxxx-1_44.lib
(2) There are four bjam compilation options. Theoretically there should be 2*2*2*2 = 16 configurations.
Ink = static | shared
Threading = single | multi
Variant = release | debug
Runtime-link = static | shared
The actual usage is mostly multithreading, so threading = multi, so the compilation configuration composed of the remaining three options is listed above, among them, the configuration of boost dynamic library with static link C ++ standard library does not exist, so there are only four cases.
(3)
Link = static: static library. The generated library file name starts with "lib"
Link = shared: dynamic library. The generated library file name does not start with "lib"
Threading = mult: multithreading is supported. The generated library file name contains "-MT"
The name of the library file generated by variant = release does not contain "-GD"
Variant = the library file name generated by debug contains "-GD"
Runtime-link = the library file name generated by static contains "-s"
Runtime-link = the library file name generated by shared does not contain "-s"