繁体   English   中英

JSONCPP 合并链接错误

[英]JSONCPP Amalgamated link errors

我正在尝试使用 jsoncpp(最新版本)的合并版本,但它产生了未解决的外部符号链接错误。 我使用的代码是

#include <json/json.h>

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

它给了我错误

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

可能您没有将 JSONCPPs *.cpp 文件包含到您的项目中(它们必须被编译和链接)。 如果库被编译为静态库,您必须告诉链接器链接什么。

我在我的 x64 版本中尝试链接 x86 版本的 JsonCpp 时得到了这个。 我没有注意到 Vcpkg 的行为就像定义了VCPKG_DEFAULT_TRIPLET=x86-windows ,除非另有说明。

发生这种情况时,我在构建日志中看到了以下条目

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