1. Download and unzip to the C-drive boost path, such as C:\boost;
2. Execute bootstrap.bat to generate Bjam.exe;
3. Compile the command as follows: The entire compilation takes about 2 hours, after running (popup input prompt)
Bjam stage --without-python --toolset=msvc-10.0 address-model=64 architecture=x86--build-type=complete --stagedir= "C:\BOOST\VC12"
Parameter description:
Stage/install:stage means that only libraries (DLLs and Lib) are generated, and install also generates an include directory with header files.
Toolset: Specifies the compiler, optional such as Borland, GCC, msvc (VC6), msvc-10.0 (VS20010), and so on. Address-model=64 for compiling 64-bit, architecture=x86 schema description
Without/with: Choose which libraries are not compiled/compiled.
Stagedir/prefix:stage when using Stagedir,install, prefix is used to indicate the path of the compiled makefile. It is recommended to specify different directories for different Ides, such as VS2013 corresponding to the VC12, otherwise it will be generated under a directory, difficult to manage.
Build-dir: The path to the intermediate file generated by the compilation. The default is the root directory (D:\BOOST\BOOST_1_46_0), the directory name is Bin.v2 (deleted), and so on after the compilation can be completely deleted (useless), so do not need to set.
Link: Generate a dynamic link library/static link library. Building a dynamic-link library requires the use of shared methods, and static-link libraries need to be built using static methods. The general boost library may be compiled in a static fashion, because the final release program feels a bit cumbersome with boost DLLs.
Runtime-link: Dynamic/static link C/C + + Runtime library. There are also shared and static two ways, so that runtime-link and link can produce a total of 4 combinations, each can choose to build according to their own needs. General link only choose static words, only need to compile 2 kinds of combinations can, namely Link=static runtime-link=shared and Link=static runtime-link=static.
Threading: Single/Multithreaded compilation. Generally write multi-threaded programs, of course, to specify the multi way, if you need to write a single-threaded program, you also need to compile a single libraries, you can use the simple.
Debug/release: Compile the debug/release version. Generally, the debug version of the program corresponds to the debug version of the library, so two are compiled.
4. Set the environment.
Modify environment variable: $ (BOOST): D:\boost\boost_1_46_0
Tools, Options, Projects and Solutions, VC + + Directories
In the library files plus $ (BOOST) \bin\vc10\lib
Add $ (BOOST) to include files
Examples of Use:
#include <boost\thread.hpp>
In this case, without a library file, the boost Auto-link mechanism will automatically help us to include the corresponding static lib. In other words, boost is statically linked by default, so our engineering properties are best set to multi-threaded (Debug). If you want to use DLL dynamic chaining, you need to pre-define macros:
#define Boost_all_dyn_link
Similarly, boost will also default to include the corresponding Lib for us at this time. If you do not want to use the Auto-link mechanism provided by boost, or if you are not comfortable with its automatic links (in fact, you can not worry about it), you can pre-define macros:
#define Boost_all_no_lib
Then use the following methods to link:
#pragma comment (lib, "Boost_thread-vc100-mt-1_46.lib") or
#pragma comment (lib, "Boost_thread-vc100-mt.lib")
The two Lib is actually the same, I really do not understand why the boost compile every library to copy one, is it because the latter after upgrading the boost version without changing the code? There's also a more useful macro:
#define Boost_lib_diagnostic
It allows the VC in the Output window at compile time to specify which boost libraries and link sequences are specifically linked by the program.
About the auto-link mechanism of boost, in detail can see the code in BOOST\CONFIG\AUTO_LINK.HPP, it is easy to read, and it is worth learning.
Reference Document: Http://www.cnblogs.com/ComputerG/archive/2011/03/10/1979730.html
Windows System compilation boost