【VS2019配置Boost】vs2019无法识别boost库目录
今天跟着llfc大佬回顾了一下boost库的配置
做个总结~
1 下载Boost
下载目录为:
https://www.boost.org/releases/1.83.0/
这里的0.7z和0.zip只是压缩率不一样,下载哪个都可以,0.7z压缩率高,解压的时候耗时长一点。

2 配置准备
1.首先解压文件
2.双击 b2.exe

3.在这个目录中打开cmd
执行如下命令:
.\b2.exe install --toolset=msvc-14.2 --build-type=complete --prefix="D:\cppsoft\boost_1_81_0" link=static runtime-link=shared threading=multi debug release
4.在VS中创建项目
3 配置
此时有两种配置Boost的方法
a. 在项目中配置

比如上图中 右键 GateSever项目,选择 属性

配置这两个目录
首先配 包含目录

选择到boost库的上一级目录,boost内包含的目录列表如下图示:

然后配置 ** 库目录** ,这个只需要将目录定位到lib就可以了,lib目录下文件集如下图所示:

上图显示的是lib下的的目录集,在配置那里编辑:
D:\A\boost_1_83_0\lib
这个方法就完了。
b. 通过 视图——>其他窗口——>属性管理器找到下图所示菜单栏,如下图所示:

选中Debug|x64 右键 ,在弹出菜单栏中选择“添加新的项目属性表”,就可以建立Propertyheet,然后双击Propertyheet就可以得到配置路径,如下图所示:

还是配置“包含目录”和“库目录”,步骤一样。
4 测试配置是否成功
用如下代码测试:
#include <iostream>
#include <string>
#include "boost/lexical_cast.hpp"
int main()
{using namespace std;cout << "Enter your weight: ";float weight;cin >> weight;string gain = "A 10% increase raises ";string wt = boost::lexical_cast<string> (weight);gain = gain + wt + " to "; // string operator()weight = 1.1 * weight;gain = gain + boost::lexical_cast<string>(weight) + ".";cout << gain << endl;system("pause");return 0;
}```如果其中一种方法配置完后vs无法识别boost目录库,就换另一种试试吧~