VS 2013 编译和使用 Boost

以 1.58.0 版本 boost 为例, 当前系统版本为 Windows 8.1 x64  

1 编译boost 

当前解压路径 "D:Librariesoost_1_58_0" 

1) 打开VS2013命令提示符 

Boost_Developer_Command_Prompt

Boost_Administrator

2) 运行 bootstrap.bat 

注意全程不要关闭命令提示符, 所有操作均在此中完成

Boost_booststrap

Boost_booststrap_comp

3) 运行 b2.exe 或 bjam.exe 

① 查看编译选项, 在命令提示符下输入"b2 --help"

Boost_b2_help

请注意以下几个编译选项

Properties:

toolset=toolset
Indicate the toolset to build with.

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.

② 编译, 在命令提示符下输入"b2 link=static threading=multi"

注意此处的选项要根据工程的需要去编译, 如果仅仅为了测试编译过程, 可以不带任何参数

Boost_b2

2 使用boost 

在工程的属性设置"VC++ Directories"中的Include和Library中增加boost, 如下图配置 

 Boost_VS2013

3 注意事项 

1) 链接不成功, 找不到xxx.lib

可能是编译选项和boost的编译选项不一致导致的,

请按照工程的编译选项重新编译boost或修改vs的配置和boost中配置一致. 

2) 多次编译boost, 使用b2编译时, 可不做清理, 可同时编译出debug和release版本, 多线程和单线程版本

原文地址:https://www.cnblogs.com/snowyying/p/3948763.html