Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

环境配置过程分享|protoc muduo boost #28

Closed
Sudingyi opened this issue Feb 6, 2024 · 15 comments
Closed

环境配置过程分享|protoc muduo boost #28

Sudingyi opened this issue Feb 6, 2024 · 15 comments

Comments

@Sudingyi
Copy link

Sudingyi commented Feb 6, 2024

分享一下我几经波折的环境配置过程,我觉得我踩了大部分的坑(一开始用的windows环境缺乏<sys/socket.h>)

0c8ab72d28a84959a32e710dad51ffcd
这里发现版本不合适,目前我的版本为libprotoc 3.19.1

项目的版本为

protoc --version                      
libprotoc 3.12.4

protoc安装传送门:https://github.com/protocolbuffers/protobuf/releases/tag/v3.12.4
boost muduo安装传送门: https://blog.csdn.net/qq_41453285/article/details/105104845

注意:对于muduo编译生成的静态文件需要移动到根目录下../build/release-cpp11/lib不然会报这个错误

cp build/release-cpp11/lib/*  /usr/lib

错误截图:
705377e39f4459e36a7f3856a1224bb

最后成功啦,成功的截图:

d7543819f14c13f22632cd15ef47c2b

653e5346486ec1e042280e776f1b6b5

Copy link

github-actions bot commented Feb 6, 2024

Message that will be displayed on users' first issue

@578223592 578223592 changed the title 配置过程 环境配置过程分享 Feb 6, 2024
@578223592
Copy link
Collaborator

感谢分享,欢迎提个pr到README文件来给仓库贡献一波 @Sudingyi

@578223592 578223592 changed the title 环境配置过程分享 环境配置过程分享|protoc muduo boost Feb 6, 2024
@578223592 578223592 pinned this issue Feb 6, 2024
@578223592 578223592 unpinned this issue Feb 6, 2024
@578223592 578223592 pinned this issue Feb 6, 2024
@578223592 578223592 unpinned this issue Feb 20, 2024
@578223592
Copy link
Collaborator

你好,我也是libprotoc 3.12.4,且moduo正确安装,cmake3.22.1,但是只编译到82%,还是会出现大量protoc的错误啊: [ 82%] Linking CXX executable ../../../../bin/provider /usr/bin/ld: CMakeFiles/provider.dir/friendService.cpp.o: in function void* google::protobuf::Arena::AllocateInternal<std::cxx11::basic_string<char, std::char_traits, std::allocator > >(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir/friendService.cpp.o: in function fixbug::GetFriendsListResponse::_internal_add_friendsabi:cxx11': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:873: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Add()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::_InternalParse(char const, google::protobuf::internal::ParseContext)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:230: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:240: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:275: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:305: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::InternalParse(char const*, google::protobuf::internal::ParseContext*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:454: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:483: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:506: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir/**/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetFriendsListResponse(google::protobuf::Arena*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:587: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::RepeatedPtrField(google::protobuf::Arena)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:587: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetFriendsListResponse(fixbug::GetFriendsListResponse const&)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:594: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::RepeatedPtrField(google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > > const&)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:594: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::~GetFriendsListResponse()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:609: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::Clear()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:641: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Clear()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_InternalParse(char const, google::protobuf::internal::ParseContext*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:671: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:683: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:720: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:737: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::size() const' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:738: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::size() const' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:740: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Get(int) const' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:751: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::MergeFrom(fixbug::GetFriendsListResponse const&)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:781: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::MergeFrom(google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > > const&)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::InternalSwap(fixbug::GetFriendsListResponse*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:808: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::InternalSwap(google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::FiendServiceRpc::descriptor()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:822: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::ResultCode(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::GetFriendsListRequest(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::GetFriendsListResponse(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function static_initialization_and_destruction_0(int, int)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:139: undefined reference to google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::io::EpsCopyOutputStream::EnsureSpace(unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:690: undefined reference to google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased(unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::EpsCopyInputStream::DoneWithCheck(char const**, int)': /usr/local/include/google/protobuf/parse_context.h:213: undefined reference to google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const*, int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::VarintParseSlow(char const*, unsigned int, unsigned int*)': /usr/local/include/google/protobuf/parse_context.h:464: undefined reference to google::protobuf::internal::VarintParseSlow32(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::VarintParseSlow(char const*, unsigned int, unsigned long*)': /usr/local/include/google/protobuf/parse_context.h:470: undefined reference to google::protobuf::internal::VarintParseSlow64(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::ReadTag(char const*, unsigned int*, unsigned int)': /usr/local/include/google/protobuf/parse_context.h:511: undefined reference to google::protobuf::internal::ReadTagFallback(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::ReadSize(char const)': /usr/local/include/google/protobuf/parse_context.h:573: undefined reference to google::protobuf::internal::ReadSizeFallback(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:180: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:344: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:481: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_internal_friends_size() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:831: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::size() const' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_internal_friendsabi:cxx11 const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:844: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Get(int) const' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function unsigned char* google::protobuf::io::EpsCopyOutputStream::WriteString<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >(unsigned int, std::_cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:736: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringOutline(unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char)' /usr/bin/ld: CMakeFiles/provider.dir/*/friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternal<google::protobuf::internal::InternalMetadata::Containergoogle::protobuf::UnknownFieldSet >(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: ../../../../lib/librpc_lib.a(mprpcchannel.cpp.o): in function google::protobuf::io::EpsCopyOutputStream::WriteRaw(void const*, int, unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:697: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteRawFallback(void const*, int, unsigned char*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::InternalParse(char const*, google::protobuf::internal::ParseContext*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:182: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:191: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:210: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:249: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:282: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function void* google::protobuf::Arena::AllocateInternalRPC::RpcHeader(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function __static_initialization_and_destruction_0(int, int)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:95: undefined reference to google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/include/rpcheader.pb.h:171: undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' collect2: error: ld returned 1 exit status make[2]: *** [example/rpcExample/callee/CMakeFiles/provider.dir/build.make:100:../bin/provider] 错误 1 make[1]: *** [CMakeFiles/Makefile2:585:example/rpcExample/callee/CMakeFiles/provider.dir/all] 错误 2 make: *** [Makefile:84:all] 错误 2

请问这怎么解决呢

@daishiqiang123 我认为问题还是出在protoc版本上,你的

protoc --version 

输出是libprotoc 3.12.4吗

@daishiqiang123
Copy link

daishiqiang123 commented Apr 21, 2024 via email

@578223592
Copy link
Collaborator

你好,我的protoc版本输出确实是3.12.4,ubuntu为20.04,所以不明确到底哪里出问题了

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2024年04月21日 17:54 | | 收件人 | @.> | | 抄送至 | @.>@.> | | 主题 | Re: [youngyangyang04/KVstorageBaseRaft-cpp] 环境配置过程分享|protoc muduo boost (Issue #28) | 你好,我也是libprotoc 3.12.4,且moduo正确安装,cmake3.22.1,但是只编译到82%,还是会出现大量protoc的错误啊: [ 82%] Linking CXX executable ../../../../bin/provider /usr/bin/ld: CMakeFiles/provider.dir/friendService.cpp.o: in function void* google::protobuf::Arena::AllocateInternal<std::cxx11::basic_string<char, std::char_traits, std::allocator > >(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir/friendService.cpp.o: in function fixbug::GetFriendsListResponse::_internal_add_friendsabi:cxx11': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:873: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Add()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::_InternalParse(char const, google::protobuf::internal::ParseContext)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:230: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:240: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:275: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:305: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::InternalParse(char const*, google::protobuf::internal::ParseContext*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:454: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:483: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:506: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetFriendsListResponse(google::protobuf::Arena*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:587: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::RepeatedPtrField(google::protobuf::Arena)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:587: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetFriendsListResponse(fixbug::GetFriendsListResponse const&)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:594: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::RepeatedPtrField(google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > > const&)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:594: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::~GetFriendsListResponse()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:609: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::Clear()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:641: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Clear()' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_InternalParse(char const, google::protobuf::internal::ParseContext*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:671: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:683: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:720: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:737: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::size() const' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:738: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::size() const' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:740: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Get(int) const' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:751: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::MergeFrom(fixbug::GetFriendsListResponse const&)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:781: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::MergeFrom(google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > > const&)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::InternalSwap(fixbug::GetFriendsListResponse*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:808: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::InternalSwap(google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::FiendServiceRpc::descriptor()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:822: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::ResultCode(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::GetFriendsListRequest(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::GetFriendsListResponse(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function static_initialization_and_destruction_0(int, int)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.cc:139: undefined reference to google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::io::EpsCopyOutputStream::EnsureSpace(unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:690: undefined reference to google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased(unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::EpsCopyInputStream::DoneWithCheck(char const, int)': /usr/local/include/google/protobuf/parse_context.h:213: undefined reference to google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const*, int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::VarintParseSlow(char const*, unsigned int, unsigned int*)': /usr/local/include/google/protobuf/parse_context.h:464: undefined reference to google::protobuf::internal::VarintParseSlow32(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::VarintParseSlow(char const*, unsigned int, unsigned long*)': /usr/local/include/google/protobuf/parse_context.h:470: undefined reference to google::protobuf::internal::VarintParseSlow64(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::ReadTag(char const*, unsigned int*, unsigned int)': /usr/local/include/google/protobuf/parse_context.h:511: undefined reference to google::protobuf::internal::ReadTagFallback(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function google::protobuf::internal::ReadSize(char const)': /usr/local/include/google/protobuf/parse_context.h:573: undefined reference to google::protobuf::internal::ReadSizeFallback(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::ResultCode::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:180: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListRequest::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:344: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:481: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_internal_friends_size() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:831: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::size() const' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_internal_friendsabi:cxx11 const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/example/rpcExample/friend.pb.h:844: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Get(int) const' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function unsigned char* google::protobuf::io::EpsCopyOutputStream::WriteString<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >(unsigned int, std::_cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:736: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringOutline(unsigned int, std::cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char)' /usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function void google::protobuf::Arena::AllocateInternal<google::protobuf::internal::InternalMetadata::Containergoogle::protobuf::UnknownFieldSet >(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: ../../../../lib/librpc_lib.a(mprpcchannel.cpp.o): in function google::protobuf::io::EpsCopyOutputStream::WriteRaw(void const*, int, unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:697: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteRawFallback(void const*, int, unsigned char*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::InternalParse(char const*, google::protobuf::internal::ParseContext*)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:182: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:191: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:210: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:249: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::ByteSizeLong() const': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:282: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function void* google::protobuf::Arena::AllocateInternalRPC::RpcHeader(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function __static_initialization_and_destruction_0(int, int)': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/rpcheader.pb.cpp:95: undefined reference to google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::GetMetadataStatic()': /home/dai/Study_Linux/c++cpp/rpc分布式/KVstorageBaseRaft-cpp-main/src/rpc/include/rpcheader.pb.h:171: undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' collect2: error: ld returned 1 exit status make[2]: *** [example/rpcExample/callee/CMakeFiles/provider.dir/build.make:100:../bin/provider] 错误 1 make[1]: *** [CMakeFiles/Makefile2:585:example/rpcExample/callee/CMakeFiles/provider.dir/all] 错误 2 make: *** [Makefile:84:all] 错误 2 请问这怎么解决呢 @daishiqiang123 我认为问题还是出在protoc版本上,你的 protoc --version 输出是libprotoc 3.12.4吗 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

@daishiqiang123 我也感到奇怪。
根据报错信息,看起来像是protoc的问题。
可以尝试一下根据.proto文件重新生成文件试试,看一下能否正常编译以及和仓库中已经生成的文件有什么区别

@daishiqiang123
Copy link

我利用proto文件重新生成cpp文件,粗略看发现和之前没什么区别,重新编译之后还是遇到上述问题,太奇怪了

@daishiqiang123
Copy link

3.12.x的版本我都试过了,依然出现这种问题

@578223592
Copy link
Collaborator

3.12.x的版本我都试过了,依然出现这种问题

@daishiqiang123 我暂时也没有太好的思路解决这个问题。
你可以尝试一下不要使用中文路径名。此外你可以新开一个issue说明一下现在的问题,看下有没有其他同学遇到了相同的问题可以帮助一下

@daishiqiang123
Copy link

好的,我排除了中文路径,但依然很会出现这个问题

@daishiqiang123
Copy link

我尝试手动添加protobuf库,就编译成功了
在cmake中添加:link_directories(/usr/local/lib/)
不过我有点疑问,为啥原cmakelists中没有对protobuf库的链接呢

@578223592
Copy link
Collaborator

我尝试手动添加protobuf库,就编译成功了 在cmake中添加:link_directories(/usr/local/lib/) 不过我有点疑问,为啥原cmakelists中没有对protobuf库的链接呢

很奇怪,按理说编译的时候的默认搜索路径就有/usr/local/lib/,不用手动指定。
不过解决了很好~

@578223592 578223592 mentioned this issue Apr 23, 2024
@WalkLull
Copy link

WalkLull commented Dec 31, 2024

【已在下一帖解决,又遇到新问题】在muduo 下运行./build.sh中遇到以下报错

环境:Ubuntu20.04
Linux 5.15
cmake 版本3.22.6
gcc:gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
protobuf:3.12.4
boost 1.71

[ 41%] Linking CXX executable ../../../bin/protobuf_rpc_wire_test
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::RpcMessage::GetMetadataStatic()': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.h:234: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function google::protobuf::io::EpsCopyOutputStream::EnsureSpace(unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:690: undefined reference to google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)'
/usr/bin/ld: /usr/local/include/google/protobuf/io/coded_stream.h:690: undefined reference to google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)' /usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)' /usr/bin/ld: /usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)'
/usr/bin/ld: /usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)' /usr/bin/ld: /usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function google::protobuf::io::EpsCopyOutputStream::EnsureSpace(unsigned char*)': /usr/local/include/google/protobuf/io/coded_stream.h:690: undefined reference to google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::MessageType_descriptor()': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.cc:103: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::ErrorCode_descriptor()': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.cc:118: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function void* google::protobuf::Arena::AllocateInternal<muduo::net::RpcMessage>(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::RpcMessage::_InternalParse(char const*, google::protobuf::internal::ParseContext*)': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.cc:341: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function google::protobuf::internal::EpsCopyInputStream::DoneWithCheck(char const**, int)': /usr/local/include/google/protobuf/parse_context.h:213: undefined reference to google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const*, int)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::RpcMessage::_InternalParse(char const*, google::protobuf::internal::ParseContext*)': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.cc:363: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function google::protobuf::internal::ReadTag(char const*, unsigned int*, unsigned int)': /usr/local/include/google/protobuf/parse_context.h:511: undefined reference to google::protobuf::internal::ReadTagFallback(char const*, unsigned int)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::RpcMessage::GetMetadataStatic()': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.h:234: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::RpcMessage::ByteSizeLong() const': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.cc:521: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function muduo::net::RpcMessage::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.cc:440: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function google::protobuf::internal::VarintParseSlow(char const*, unsigned int, unsigned long*)': /usr/local/include/google/protobuf/parse_context.h:470: undefined reference to google::protobuf::internal::VarintParseSlow64(char const*, unsigned int)'
/usr/bin/ld: ../../../lib/libmuduo_protorpc_wire.a(rpc.pb.cc.o): in function _GLOBAL__sub_I__ZN5muduo3net29_RpcMessage_default_instance_E': /home/horse/Desktop/Package/build/release-cpp11/muduo/net/protorpc/rpc.pb.cc:99: undefined reference to google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)'
collect2: error: ld returned 1 exit status
make[2]: *** [muduo/net/protorpc/CMakeFiles/protobuf_rpc_wire_test.dir/build.make:101: bin/protobuf_rpc_wire_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:2402: muduo/net/protorpc/CMakeFiles/protobuf_rpc_wire_test.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

@WalkLull
Copy link

同上 使用
set(PROTOBUF_PROTOC_EXECUTABLE /usr/local/bin/protoc)手动指明protoc可执行文件,link_directories(/usr/local/lib)指明库文件路径
include_directories(/usr/local/include)指明头文件路径后
muduo编译安装通过。

现在又遇到新问题,执行
horse@horse-linux:~/Desktop/KVstorageBaseRaft-cpp/cmake-build-debug$ make
报错:
[ 78%] Linking CXX executable ../../../../bin/provider
/usr/bin/ld: CMakeFiles/provider.dir/friendService.cpp.o: in function void* google::protobuf::Arena::AllocateInternal<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(bool)': /usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)'
/usr/bin/ld: CMakeFiles/provider.dir/friendService.cpp.o: in function fixbug::GetFriendsListResponse::_internal_add_friends[abi:cxx11]()': /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.h:873: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::Add()'
/usr/bin/ld: CMakeFiles/provider.dir/
/friend.pb.cc.o: in function fixbug::ResultCode::_InternalParse(char const*, google::protobuf::internal::ParseContext*)': /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:230: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)'
/usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:240: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::ResultCode::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:275: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::ResultCode::ByteSizeLong() const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:305: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListRequest::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:454: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListRequest::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:483: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListRequest::ByteSizeLong() const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:506: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetFriendsListResponse(google::protobuf::Arena*)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:587: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::RepeatedPtrField(google::protobuf::Arena*)' /usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:587: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::~RepeatedPtrField()'
/usr/bin/ld: CMakeFiles/provider.dir/
/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetFriendsListResponse(fixbug::GetFriendsListResponse const&)': /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:594: undefined reference to google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > >::RepeatedPtrField(google::protobuf::RepeatedPtrField<std::cxx11::basic_string<char, std::char_traits, std::allocator > > const&)'
/usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:594: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::~GetFriendsListResponse()':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:609: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~RepeatedPtrField()' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::Clear()':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:641: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Clear()' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:671: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:683: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)'
/usr/bin/ld: CMakeFiles/provider.dir//friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const': /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:720: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)'
/usr/bin/ld: CMakeFiles/provider.dir/
/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::ByteSizeLong() const': /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:737: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >::size() const'
/usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:738: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::size() const' /usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:740: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >::Get(int) const'
/usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:751: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::MergeFrom(fixbug::GetFriendsListResponse const&)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:781: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::MergeFrom(google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::InternalSwap(fixbug::GetFriendsListResponse*)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:808: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::InternalSwap(google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::FiendServiceRpc::descriptor()':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:822: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::ResultCode(bool)':
/usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::GetFriendsListRequest(bool)':
/usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternalfixbug::GetFriendsListResponse(bool)':
/usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function __static_initialization_and_destruction_0(int, int)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.cc:139: undefined reference to google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function google::protobuf::io::EpsCopyOutputStream::EnsureSpace(unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:690: undefined reference to google::protobuf::io::EpsCopyOutputStream::EnsureSpaceFallback(unsigned char*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliased(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:719: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringMaybeAliasedOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function google::protobuf::internal::EpsCopyInputStream::DoneWithCheck(char const**, int)':
/usr/local/include/google/protobuf/parse_context.h:213: undefined reference to google::protobuf::internal::EpsCopyInputStream::DoneFallback(char const*, int)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function google::protobuf::internal::VarintParseSlow(char const*, unsigned int, unsigned int*)':
/usr/local/include/google/protobuf/parse_context.h:464: undefined reference to google::protobuf::internal::VarintParseSlow32(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function google::protobuf::internal::VarintParseSlow(char const*, unsigned int, unsigned long*)':
/usr/local/include/google/protobuf/parse_context.h:470: undefined reference to google::protobuf::internal::VarintParseSlow64(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function google::protobuf::internal::ReadTag(char const*, unsigned int*, unsigned int)':
/usr/local/include/google/protobuf/parse_context.h:511: undefined reference to google::protobuf::internal::ReadTagFallback(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function google::protobuf::internal::ReadSize(char const**)':
/usr/local/include/google/protobuf/parse_context.h:573: undefined reference to google::protobuf::internal::ReadSizeFallback(char const*, unsigned int)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::ResultCode::GetMetadataStatic()':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.h:180: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListRequest::GetMetadataStatic()':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.h:344: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::GetMetadataStatic()':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.h:481: undefined reference to google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_internal_friends_size() const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.h:831: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::size() const' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function fixbug::GetFriendsListResponse::_internal_friendsabi:cxx11 const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/example/rpcExample/friend.pb.h:844: undefined reference to google::protobuf::RepeatedPtrField<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::Get(int) const' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function unsigned char* google::protobuf::io::EpsCopyOutputStream::WriteString<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >(unsigned int, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:736: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteStringOutline(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)' /usr/bin/ld: CMakeFiles/provider.dir/__/friend.pb.cc.o: in function void* google::protobuf::Arena::AllocateInternal<google::protobuf::internal::InternalMetadata::Containergoogle::protobuf::UnknownFieldSet >(bool)':
/usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: ../../../../lib/librpc_lib.a(mprpcchannel.cpp.o): in function google::protobuf::io::EpsCopyOutputStream::WriteRaw(void const*, int, unsigned char*)':
/usr/local/include/google/protobuf/io/coded_stream.h:697: undefined reference to google::protobuf::io::EpsCopyOutputStream::WriteRawFallback(void const*, int, unsigned char*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::_InternalParse(char const*, google::protobuf::internal::ParseContext*)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/src/rpc/rpcheader.pb.cpp:182: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/src/rpc/rpcheader.pb.cpp:191: undefined reference to google::protobuf::internal::InlineGreedyStringParser(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, char const, google::protobuf::internal::ParseContext*)'
/usr/bin/ld: /home/horse/Desktop/KVstorageBaseRaft-cpp/src/rpc/rpcheader.pb.cpp:210: undefined reference to google::protobuf::internal::UnknownFieldParse(unsigned long, google::protobuf::UnknownFieldSet*, char const*, google::protobuf::internal::ParseContext*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::_InternalSerialize(unsigned char*, google::protobuf::io::EpsCopyOutputStream*) const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/src/rpc/rpcheader.pb.cpp:249: undefined reference to google::protobuf::internal::WireFormat::InternalSerializeUnknownFieldsToArray(google::protobuf::UnknownFieldSet const&, unsigned char*, google::protobuf::io::EpsCopyOutputStream*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::ByteSizeLong() const':
/home/horse/Desktop/KVstorageBaseRaft-cpp/src/rpc/rpcheader.pb.cpp:282: undefined reference to google::protobuf::internal::ComputeUnknownFieldsSize(google::protobuf::internal::InternalMetadata const&, unsigned long, google::protobuf::internal::CachedSize*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function void* google::protobuf::Arena::AllocateInternalRPC::RpcHeader(bool)':
/usr/local/include/google/protobuf/arena.h:536: undefined reference to google::protobuf::Arena::AllocateAlignedNoHook(unsigned long)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function __static_initialization_and_destruction_0(int, int)':
/home/horse/Desktop/KVstorageBaseRaft-cpp/src/rpc/rpcheader.pb.cpp:95: undefined reference to google::protobuf::internal::AddDescriptors(google::protobuf::internal::DescriptorTable const*)' /usr/bin/ld: ../../../../lib/librpc_lib.a(rpcheader.pb.cpp.o): in function RPC::RpcHeader::GetMetadataStatic()':
/home/horse/Desktop/KVstorageBaseRaft-cpp/src/rpc/include/rpcheader.pb.h:171: undefined reference to `google::protobuf::internal::AssignDescriptors(google::protobuf::internal::DescriptorTable const*, bool)'
collect2: error: ld returned 1 exit status
make[2]: *** [example/rpcExample/callee/CMakeFiles/provider.dir/build.make:114: ../bin/provider] Error 1
make[1]: *** [CMakeFiles/Makefile2:542: example/rpcExample/callee/CMakeFiles/provider.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

环境同上没变,仍然和protobuf有关。。。没头绪啊,这种问题应该怎么解决

@WalkLull
Copy link

WalkLull commented Jan 9, 2025

在仔细阅读protoc使用教程后意识到报错均来自 friend.pb.h、friend.pb.cc等由protoc complier自主生成的文件,报错均为undefined reference,意识到example文件夹下的friend.protoc是由作者预编译的,这里可能有某种bug。遂删除example/rpcExample/ 下的friend.pb.h、friend.pb.cc,使用 protoc friend.proto --cpp_out=. ,重新编译。最终成功make

@578223592
Copy link
Collaborator

d

@WalkLull 感谢反馈。
这样说的话原因可能还是protoc的版本不一致造成的~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants