我能够使用JsonCPP(https://github.com/open-source-parsers/jsoncpp)创建一个测试WinApp来解析json文件。 但是,当我在MFC C ++项目中实现类似的 C / C ++ - >在VS2008中将预编译标题选项设置为使用预编译标题(/ Yu),它会因此错误而失败:
c:\ users \ user1 \ documents \ visual studio 2008 \ projects \ jsonutility \ jsonutility \ jsonTest.cpp(371):致命错误C1010:查找预编译头时意外结束文件。您是否忘记在源代码中添加“#include”stdafx.h“'?
如果我将“#include”stdafx.h“'添加到我的JsonTest.cpp中,我会收到此错误:
JsonTest.obj:错误LNK2019:未解析的外部符号“public:class Json :: Value& __thiscall Json :: Value :: operator [](char const *)”(?? AValue @ Json @@ QAEAAV01 @ PBD @Z)在函数“public:void __thiscall JsonTest :: readConfig(char const *)”中引用(?readConfig @JsonTest @@ QAEXPBD @ Z)
我已经尝试了将近2天但没有成功。 我在附加包含目录中添加了以下内容:
C:\ Users \ User1 \ Documents \ Visual Studio 2008 \ Projects \ JsonUtility \ ReadingJson \ dist
C:\ Program Files(x86)\ Microsoft Visual Studio 9.0 \ VC \ include
C:\ USR \ jsoncpp主\包括
答案 0 :(得分:1)
我好像你没有将JSONCPPs * .cpp文件包含到你的项目中(它们必须被编译和链接)。如果库被编译到静态库,则必须告诉链接器要链接的内容。