6

I am trying to use the amalgamated version of jsoncpp(the latest version), but it is producing unresolved external symbol link errors. The code I am using is

#include <json/json.h>

int main(){
   Json::Value root;
   return 0;
}

and it is giving me the error

1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Json::Value::~Value(void)" (??1Value@Json@@QAE@XZ) referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Json::Value::Value(enum Json::ValueType)" (??0Value@Json@@QAE@W4ValueType@1@@Z) referenced in function _main
user975989
  • 2,578
  • 1
  • 20
  • 38

2 Answers2

6

Probably 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.

Simon
  • 1,496
  • 8
  • 11
  • 1
    Thanks, I forgot to do that. I also had to add assertions.h to amalgamated.py because the dev forgot to do that which gave me assert errors. – user975989 Oct 03 '11 at 21:38
  • 1
    Yes, I had to add the files in :\jsoncpp-0.10.5\src\lib_json, in order for the link errors to go away!!! – Aaron Gong May 26 '16 at 17:45
0

I got this when trying to link x86 version of JsonCpp in my x64 build. I did not notice that Vcpkg behaves as if VCPKG_DEFAULT_TRIPLET=x86-windows was defined, unless it's told otherwise.

I saw the following entry in the build log when that was happening

C:\Tools\vcpkg\installed\x86-windows\debug\lib\jsoncpp.lib : warning LNK4272: library machine type 'x86' conflicts with target machine type 'x64' [C:\projects\qpid-proton\BLD\cpp\qpid-proton-cpp.vcxproj]

user7610
  • 25,267
  • 15
  • 124
  • 150