0
votes

I was able to create a test WinApp using JsonCPP (https://github.com/open-source-parsers/jsoncpp) to parse a json file. However, when I implemented similar in an MFC C++ project with C/C++ -> Precompiled Headers option set to Use Precompiled Header(/Yu) in VS2008, it fails with this error:

c:\users\user1\documents\visual studio 2008\projects\jsonutility\jsonutility\jsonTest.cpp(371) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?

If I add '#include "stdafx.h"' to my JsonTest.cpp, I will get this error:

JsonTest.obj : error LNK2019: unresolved external symbol "public: class Json::Value & __thiscall Json::Value::operator[](char const *)" (??AValue@Json@@QAEAAV01@PBD@Z) referenced in function "public: void __thiscall JsonTest::readConfig(char const *)" (?readConfig@JsonTest@@QAEXPBD@Z)

I have tried for almost 2 days now but no success. I had added the following in my Additional Include Directories:

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-master\include

1
That is a linker error. If you've built jsoncpp you should have a .lib file. Add the .lib file to your project's Configuration Properties > Linker > Input > Additional Dependencies.acraig5075

1 Answers

1
votes

I seems like you didn't include the JSONCPPs *.cpp file into your project (they have to be compiled and linked). If the library gets compiled to a static library, you have to tell the linker what to link.