VS2013 compilation boost_1_58_0 detailed steps

1. Download the source code package from boost official website ( https://www.boost.org/users/download/ ) and unzip it.

The editor uses the boost_1_58_0 version, if you want to use this version, you can get it from here (link: https://pan.baidu.com/s/1v5KHLSYjtBeXIFoZlSExpA 
extraction code: zxf8 )Ψ( ̄∀ ̄)Ψ

 

2. Open the developer command prompt of vs2013 as an administrator, as shown in the figure

To compile the 64-bit boost library, please select "VS2013 x64 Compatible Tool Command Prompt" and open it as an administrator.

 

3. Locate the boost source code directory, for example, the editor’s directory is E:\workspace\boost\boost_1_58_0, as shown in the figure

 

4. Execute the bootstrap.bat command to create a compilation tool.

After the command is executed, you can see that four files, b2.exe, bjam.exe, project-config.jam, and bootstrap.log, have been generated in the directory.

Among them, b2.exe, bjam.exe these two exe functions are the same, bjam.exe is the old version, b2 is the upgraded version of bjam.

 

5. Enter the command to compile

b2 stage --toolset=msvc-12.0 --without-python --stagedir="D:\Boost\boost_1_68_0\bin\vc12" link=static runtime-link=shared  threading=multi debug release 

Press Enter, wait patiently for a while, and the library will be compiled. . .

The instruction parameters are as follows:

(1)stage/install:

Stage means that only libraries (dll and lib) are generated, and install also generates an include directory containing header files. I recommend using stage, because the include directory generated by install is actually the boost directory after the boost installation package is decompressed (E:\SDK\boost\boost, only a few more non-hpp files than the include directory, which are very small), so It can be used directly, and different IDEs can use the same set of header files, which saves both compilation time and hard disk space.

(2)toolset:

Specify the compiler, optional such as borland, gcc, msvc (VC6), msvc-9.0 (VS2008), etc.

(3)without/with:

Choose which libraries not to compile/compile. Because I don't need libraries such as python and mpi, so I excluded them. There are also static libs compiled by wave, graph, math, regex, test, program_options, serialization, signals, which are very large, so those that are not needed can be removed without. This can be selected according to the needs of each person, and the default is to compile all. But it should be noted that if you choose to compile python, you need python language support, and you should download and install it from the official python homepage http://www.python.org/.

The command to view the libraries included in boost is bjam --show-libraries .

(4)stagedir/prefix:

Use stagedir for stage and prefix for install to indicate the path of the compiled files. It is recommended to specify different directories for different IDEs. For example, VS2008 corresponds to E:\SDK\boost\bin\vc9, and VC6 corresponds to E:\SDK\boost\bin\vc6. Otherwise, it is difficult to generate them under one directory. management. If the install parameter is used, the header file directory will also be generated. vc9 corresponds to E:\SDK\boost\bin\vc9\include\boost-1_46\boost, similar to vc6 (this path is so cumbersome, or use stage it is good).

(5)build-dir:

The path of the intermediate file generated by the compilation. I don’t use this here. By default, it’s under the root directory (E:\SDK\boost), and the directory is named bin.v2. After the compilation is complete, this directory can be deleted (useless), so there is no need to set it up .

(6)link:

Generate dynamic link library/static link library. The shared method must be used to generate the dynamic link library, and the static method must be used to generate the static link library. Generally, boost libraries may be compiled in static mode, because the final release of the program with boost dll feels more cumbersome.

(7)runtime-link:

Dynamic/static link C/C++ runtime library . There are also shared and static two ways, so runtime-link and link can produce a total of 4 combinations, and everyone can choose to compile according to their needs.

(8)threading:

Single/multi-threaded compilation. Generally, multi-threaded programs are written, of course, the multi mode must be specified; if you need to write a single-threaded program, then you also need to compile a single-threaded library, you can use the single mode.

(9)debug/release:

Compile the debug/release version. Generally, the debug version of the program corresponds to the debug version of the library, so both are compiled.

For more information, please refer to : https://www.cnblogs.com/zhcncn/p/3950477.html

Another: If you want to compile the 64-bit version of the library, you also need to use the following parameter
address-model=64: Compiling 64-bit is an indispensable command

 

6. Use boost library

After the compilation is completed, the corresponding lib file will be generated in boost_1_58_0\bin\vc12, and there will be a bin.v2 folder in the boost_1_58_0 directory. This folder is a temporary folder during compilation. We will delete it directly.

For ease of use, we configure the relevant environment variables:

(1) Cut the lib folder in bin\vc12 to the C:\Third-libs\boost-1.58\Win32\ folder;

(2) Create a new include folder in C:\Third-libs\boost-1.58\Win32\, and copy boost from the source directory of boost_1_58_0 to the include directory.

(3) In the environment variables, add user variables as follows

7. After the configuration is completed, it can be configured and used in our project, as shown below

In our project, add the boost library header file path in the additional include directory,

Add the boost library lib file path in the additional library directory

The next step is to write code to call. . . . d=====( ̄▽ ̄*)b top

Guess you like

Origin blog.csdn.net/lt4959/article/details/108974041