文章目录
vs2019配置c++ boost库
安装编译Boost c++ library
-
安装Boost库
官网下载:https://www.boost.org/users/history/version_1_70_0.html
最新版本1.70.0. (低于1.7.0的版本可能在vs2019中支持不完善,编译或运行时发生不可预料的bug)
-
下载好后,解压,得到文件目录如下图,找到其中的bootstrap.bat文件:
双击运行可能出现闪退,最好的办法(亲测有效): 选择vs2019 —> visual studio tools —> vc —> x86_x64 Cross Tools Command Prompt for VS 2,打开命令行:
切换到boost_1_70_0的安装目录,(本人安装路径:E:\program\boost_1_70_0)cd E:\program\boost_1_70_0 bootstrap.bat # 执行
执行会发现当前文件夹中增加了几个文件,找到其中的bjam.exe,如下图所示
命令行执行:
bjam.exe --toolset=msvc-14.1 architecture=x86 address-model=64 link=static --build-type=complete --with-system --with-thread --with-date_time --with-filesystem --with-serialization
Note:
- MSVC 版本号对应
- vs2019 可以支持boost c++ library 针对msvc-14.1的编译选项
等待5-10min即可完成。
最后两个路径会在使用Boost库时工程属性中包含目录和库目录中用到。
The Boost C++ Libraries were successfully built.
the following directory should be added to compiler include paths:
E:\program\boost_1_70_0
the following directory should be added to linker library paths:
E:\program\boost_1_70_0\stage\lib
这时boost库已经安装、编译成功。
新建vs2019 c++项目,并添加boost依赖库
点击菜单栏 项目——>属性——>选择VC++目录,在包含目录 和 库目录添加以上2个路径,如下图: