在VS中使用Boost库

时间:2024-05-18 17:08:45

在VS2015中使用Boost库

所以发这篇文记录下自己的步骤,本文针对首次使用boost并希望快速配置boost的同学,配置中固然以简单快速为主,不涉及其他高级用法

1、下载boost最新库

(a) 官网直接点击如图的Version

在VS2015中使用Boost库
官网

(b) 根据自己平台情况需求下载对应的版本

在VS2015中使用Boost库
版本选择

(c) 下载后解压得到:

在VS2015中使用Boost库
解压目录

2、编译适应自己平台的Boost库

(a) 找到VS自带的x86本机工具命令提示符

在VS2015中使用Boost库
选择VS本机工具命令提示符

(b) 进入解压目录并执行该目录下的bootstrap.bat,执行后该目录下会生成b2.exe和bjam.exe

在VS2015中使用Boost库
执行boostrap.bat
在VS2015中使用Boost库
生成文件

(c) 执行b2.exe,等待直到编译完成

在VS2015中使用Boost库
编译完成

编译64位:

五、使用bjam编译boost库

命令:

bjam install stage --toolset=msvc-14.0 --stagedir="D:\soft\c++\boost64" link=static runtime-link=static threading=multi address-model=64 debug release

bjam install stage --toolset=msvc-14.0 --stagedir="E:\C++library\boost_1_64_0\x64\shared" link=static runtime-link=shared threading=multi  address-model=64 debug release

3、为VS项目配置boost

(a) 项目右键 选择属性,选择VC++目录 。在包含目录和库目录分别配置上boost解压根目录和bootst解压根目录下\stage\lib,如下:

在VS2015中使用Boost库
VC++目录和库配置

(b) 然后在链接器-常规下的 附加库目录配置如上步骤的lib目录,如下:

在VS2015中使用Boost库
链接器附加库目录配置

所有步骤完成!可以开始写代码了!

#include "boost/xxxx.hpp"~~~