简体   繁体   English

JSONCPP 合并链接错误

[英]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.我正在尝试使用 jsoncpp(最新版本)的合并版本,但它产生了未解决的外部符号链接错误。 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

Probably you didn't include the JSONCPPs *.cpp file into your project (they have to be compiled and linked).可能您没有将 JSONCPPs *.cpp 文件包含到您的项目中(它们必须被编译和链接)。 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.我在我的 x64 版本中尝试链接 x86 版本的 JsonCpp 时得到了这个。 I did not notice that Vcpkg behaves as if VCPKG_DEFAULT_TRIPLET=x86-windows was defined, unless it's told otherwise.我没有注意到 Vcpkg 的行为就像定义了VCPKG_DEFAULT_TRIPLET=x86-windows ,除非另有说明。

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] C:\\Tools\\vcpkg\\installed\\x86-windows\\debug\\lib\\jsoncpp.lib:警告 LNK4272:库机器类型“x86”与目标机器类型“x64”冲突 [C:\\projects\\qpid-proton\\BLD\\ cpp\\qpid-proton-cpp.vcxproj]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM