我正在尝试将 rapidjson
库包含在我的 VS 社区 2017 项目中。
在创建新项目时,我尝试在以下位置包含/添加目录 rapidjson-master\include\rapidjson
:
属性 -> 配置属性 -> C/C++ -> 常规 -> 附加包含目录。
属性 -> 配置属性 -> VC++ 目录 -> 包含目录。
无论哪种方式,当我尝试包含一个 rapidjson
相关文件时,VS 告诉我它找不到源文件。
所以,当我给出这个时:
#include "rapidjson/document.h"
#include "rapidjson/writer.h"
#include "rapidjson/stringbuffer.h"
我收到以下错误:
Error (active) E1696 cannot open source file "rapidjson/document.h"
Error (active) E1696 cannot open source file "rapidjson/writer.h"
Error (active) E1696 cannot open source file "rapidjson/stringbuffer.h"
VS 信息:
Microsoft Visual Studio Community 2017
Version 15.6.3
如果您知道在 Visual Studio 中使用 rapidjson
的正确方法,请告诉我。
编辑:
rapidjson documentation建议我们“只需将 include/rapidjson
文件夹复制到系统或项目的包含路径”。
最佳答案
看起来包含路径应该只是 rapidjson-master\include
,但让我们从头开始。
克隆 rapidjson 存储库;在命令窗口中执行以下操作:
mkdir C:/ThirdParty cd C:/ThirdParty git clone https://github.com/Tencent/rapidjson.git
用一个方便的目录代替
C:/ThirdParty
。在 Visual Studio 中,打开解决方案,然后在解决方案资源管理器中,选择使用 rapidjson 的项目,然后使用主菜单的“项目属性”功能,或者右键单击项目并从选项菜单中选择“属性”。这将显示“属性”对话框。
在对话框左侧的列表中选择 C/C++ General。
现在在对话框的右侧,第一行应该是“Additional Include Directories”。编辑该行,在列表末尾添加
C:/ThirdParty/rapidjson/include
。
关于c++ - 无法在 VS2017 中包含 rapidjson 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50798218/