未解析的外部符号 - GRPC

Posted

技术标签:

【中文标题】未解析的外部符号 - GRPC【英文标题】:unresolved external symbol - GRPC 【发布时间】:2019-09-23 19:56:48 【问题描述】:

我使用 protoc 编译器编译了 c++ grpc 文件,所以我认为引用不应该有任何问题。 我添加了 "grpc\include" 、 "grpc\src" 和 "grpc\third_party\protobuf\src\google\protobuf" 作为包含目录。 有趣的是,我得到了:

error LNK2019: unresolved external symbol "public: __thiscall google::protobuf::internal::LogMessage::LogMessage(enum google::protobuf::LogLevel,char const *,int)" (??0LogMessage@internal@protobuf@google@@QAE@W4LogLevel@23@PBDH@Z) referenced in function "int __cdecl google::
error LNK2001: unresolved external symbol "public: virtual bool __thiscall google::protobuf::io::ZeroCopyOutputStream::WriteAliasedRaw(void const *,int)" (?WriteAliasedRaw@ZeroCopyOutputStream@io@protobuf@google@@UAE_NPBXH@Z)
error LNK2019: unresolved external symbol "public: bool __thiscall google::protobuf::MessageLite::ParseFromZeroCopyStream(class google::protobuf::io::ZeroCopyInputStream *)" (?ParseFromZeroCopyStream@MessageLite@protobuf@google@@QAE_NPAVZeroCopyInputStream@io@23@@Z) referenced in function "class grpc::Status __cdecl grpc::GenericDeserialize<class grpc::ProtoBufferReader,class facialpluginpoc::NoParams>(class grpc::ByteBuffer *,class google::protobuf::MessageLite *)" (??$GenericDeserialize@VProtoBufferReader@grpc@@VNoParams@facialpluginpoc@@@grpc@@YA?AVStatus@0@PAVByteBuffer@0@PAVMessageLite@protobuf@google@@@Z)
error LNK2001: unresolved external symbol "class grpc::CoreCodegenInterface * grpc::g_core_codegen_interface" (?g_core_codegen_interface@grpc@@3PAVCoreCodegenInterface@1@A)
error LNK2001: unresolved external symbol "class grpc::GrpcLibraryInterface * grpc::g_glip" (?g_glip@grpc@@3PAVGrpcLibraryInterface@1@A)
error LNK2019: unresolved external symbol "void __cdecl google::protobuf::internal::VerifyVersion(int,int,char const *)" (?VerifyVersion@internal@protobuf@google@@YAXHHPBD@Z) referenced in function "void __cdecl InitDefaultsscc_info_NoParams_facialpluginpoc_2eproto(void)" (?InitDefaultsscc_info_NoParams_facialpluginpoc_2eproto@@YAXXZ)
1>facialpluginpoc.pb.obj : error LNK2019: unresolved external symbol "void __cdecl google::protobuf::internal::OnShutdownRun(void (__cdecl*)(void const *),void const *)" (?OnShutdownRun@internal@protobuf@google@@YAXP6AXPBX@Z0@Z) referenced in function "void __cdecl google::protobuf::internal::OnShutdownDestroyMessage(void const *)" (?OnShutdownDestroyMessage@internal@protobuf@google@@YAXPBX@Z)
1>facialpluginpoc.pb.obj : error LNK2019: unresolved external symbol "private: __int64 __thiscall google::protobuf::io::CodedInputStream::ReadVarint32Fallback(unsigned int)" (?ReadVarint32Fallback@CodedInputStream@io@protobuf@google@@AAE_JI@Z) referenced in function "public: bool __thiscall google::protobuf::io::CodedInputStream::ReadVarint32(unsigned int *)" (?ReadVarint32@CodedInputStream@io@protobuf@google@@QAE_NPAI@Z)
1>facialpluginpoc.pb.obj : error LNK2019: unresolved external symbol "private: unsigned int __thiscall google::protobuf::io::CodedInputStream::ReadTagFallback(unsigned int)" (?ReadTagFallback@CodedInputStream@io@protobuf@google@@AAEII@Z) referenced in function "public: struct std::pair<unsigned int,bool> __thiscall google::protobuf::io::CodedInputStream::ReadTagWithCutoffNoLastTag(unsigned int)" (?ReadTagWithCutoffNoLastTag@CodedInputStream@io@protobuf@google@@QAE?AU?$pair@I_N@std@@I@Z)
1>facialpluginpoc.pb.obj : error LNK2019: unresolved external symbol "public: static unsigned char * __cdecl google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned char *)" (?WriteStringWithSizeToArray@CodedOutputStream@io@protobuf@google@@SAPAEABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAE@Z) referenced in function "public: static unsigned char * __cdecl google::protobuf::internal::WireFormatLite::WriteBytesToArray(int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned char *)" (?WriteBytesToArray@WireFormatLite@internal@protobuf@google@@SAPAEHABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAE@Z)
1>facialpluginpoc.pb.obj : error LNK2019: unresolved external symbol "public: void * __thiscall google::protobuf::internal::ArenaImpl::AllocateAligned(unsigned int)" (?AllocateAligned@ArenaImpl@internal@protobuf@google@@QAEPAXI@Z) referenced in function "private: void * __thiscall google::protobuf::Arena::AllocateInternal<struct google::protobuf::internal::InternalMetadataWithArenaBase<class google::protobuf::UnknownFieldSet,class google::protobuf::internal::InternalMetadataWithArena>::Container>(bool)" (??$AllocateInternal@UContainer@?$InternalMetadataWithArenaBase@VUnknownFieldSet@protobuf@google@@VInternalMetadataWithArena@internal@23@@internal@protobuf@google@@@Arena@protobuf@google@@AAEPAX_N@Z)
 error LNK2019: unresolved external symbol "public: static bool __cdecl google::protobuf::internal::WireFormatLite::ReadBytes(class google::protobuf::io::CodedInputStream *,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *)" (?ReadBytes@WireFormatLite@internal@protobuf@google@@SA_NPAVCodedInputStream@io@34@PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "public: virtual bool __thiscall facialpluginpoc::Result::MergePartialFromCodedStream(class google::protobuf::io::CodedInputStream *)" (?MergePartialFromCodedStream@Result@facialpluginpoc@@UAE_NPAVCodedInputStream@io@protobuf@google@@@Z)

我已将所有必需的头文件作为项目依赖项包含在内,但仍然面临这个问题。 这是 GRPC 库/构建/环境问题吗?如何解决?

【问题讨论】:

请阅读What is an undefined reference/unresolved external symbol error and how do I fix it? 【参考方案1】:

C++ 有两个阶段compilinglinking。从帖子中的错误来看,您的包含很好,没有给出任何编译器错误,但都是链接器错误。在链接阶段,它可能会丢失"google::protobuf::io" librarylib 文件。

【讨论】:

以上是关于未解析的外部符号 - GRPC的主要内容,如果未能解决你的问题,请参考以下文章

OpenCV:未解析的外部符号

C++ - 未解析的外部符号

未解析的外部符号 C++

未引用函数的“未解析的外部符号”

错误 LNK2001:未解析的外部符号 WINAPI [重复]

错误 LNK2001:未解析的外部符号