未解析的外部符号 - GRPC

问题描述 投票:0回答:2

我使用 protoc 编译器编译了 c++ grpc 文件,所以我认为引用应该不会产生任何问题。 我添加了 "grpc\include" 、 "grpc\src" 和 "grpc hird_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 库/构建/环境问题吗?怎么解决这个问题?

c++ visual-studio visual-c++ protocol-buffers grpc
2个回答
0
投票

C++ 有两个阶段

compiling
linking
。从帖子中的错误来看,您的包含内容似乎很好,没有给出任何编译器错误,但都是链接器错误。在链接阶段,可能会丢失
"google::protobuf::io" library
lib
文件。


0
投票

对于我来说,应用了以下解决方案: 在编译 GRPC 之前,我已经在 Linux 中安装了 protoc 和 protobuf。在这种情况下,GRPC 决定 PROTOBUF 不需要再次编译。但是变化很大,程序尝试链接错误版本的 libGRPC 和 libprotobuf。最好是卸载所有 protobuf 版本,然后删除 protoc、libproto* 的剩余部分,然后再次编译 GRPC。应构建 GRPC 来生成共享库并将其安装在 Linux 中。通过这样做,在链接期间始终使用正确的版本。

© www.soinside.com 2019 - 2024. All rights reserved.