JSONCPP Amalgamated link errors
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(en开发者_C百科um Json::ValueType)" (??0Value@Json@@QAE@W4ValueType@1@@Z) referenced in function _main
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.
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]
精彩评论