What version of protobuf and what language are you using?
Version: v3.12.4
Language: C++
"Please try updating to the latest version of protoc/runtime possible beforehand to attempt to resolve your problem?" I think it may not useful for me.
What operating system (Linux, Windows, ...) and version?
Linux 5.19.0-35-generic, Ubuntu
What runtime / compiler are you using (e.g., python version or gcc version)
gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Python 3.10.6
What did you do?
Steps to reproduce the behavior:
1.sudo apt-get install libprotoc-dev protobuf-compiler libprotobuf-dev
So I use the default version of the system, and protoc is also 3.12.4 (so there is no conflict between protoc and protobuf).
But when I compile my project, cmake give me annoying errors as follows:
**there are so many undefined references, I can't understand them. Please hele me!!! I think that their definitions have been in system files in /usr/lib, but why these errors?**
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=../debug-install-cpp11 -DMUDUO_PATH=/home/cyf/cpp-projects/muduo-protorpc/../build/debug-install-cpp11 /home/cyf/cpp-projects/muduo-protorpc
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- cmake_build_type: debug
-- muduo_path: /home/cyf/cpp-projects/muduo-protorpc/../build/debug-install-cpp11
-- Muduo include /home/cyf/cpp-projects/build/debug-install-cpp11/include
-- Muduo lib /home/cyf/cpp-projects/build/debug-install-cpp11/lib
-- /home/cyf/cpp-projects/build/debug-install-cpp11/lib/libmuduo_base.a
-- /home/cyf/cpp-projects/build/debug-install-cpp11/lib/libmuduo_net.a
-- /home/cyf/cpp-projects/build/debug-install-cpp11/lib/libmuduo_protorpc_wire.a
-- /home/cyf/cpp-projects/build/debug-install-cpp11/lib/libmuduo_cdns.a
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake (found version "1.74.0")
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (found version "3.12.4")
-- found tcmalloc
-- Configuring done
-- Generating done
-- Build files have been written to: /home/cyf/cpp-projects/build/protorpc-debug
What did you expect to see
Hope to compile completely and produce library for my own use.
What did you see instead?
I try all solutions mentioned from Internet, whether stackoverflow or google. For example:
Add -D_GLIBCXX_USE_CXX11_ABI=0, or -lprotoc -lprotobuf -lpthread
or force to link static library libprotobuf.a.
and other unuseful solutions.
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment
What version of protobuf and what language are you using? Version: v3.12.4 Language: C++ "Please try updating to the latest version of protoc/runtime possible beforehand to attempt to resolve your problem?" I think it may not useful for me.
What operating system (Linux, Windows, ...) and version? Linux 5.19.0-35-generic, Ubuntu
What runtime / compiler are you using (e.g., python version or gcc version) gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0 Python 3.10.6
What did you do? Steps to reproduce the behavior: 1.sudo apt-get install libprotoc-dev protobuf-compiler libprotobuf-dev So I use the default version of the system, and protoc is also 3.12.4 (so there is no conflict between protoc and protobuf).
[cyf@vm ~/cpp-projects/muduo-protorpc]$ ./build.sh
-- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so (found version "3.12.4") -- found tcmalloc -- Configuring done -- Generating done -- Build files have been written to: /home/cyf/cpp-projects/build/protorpc-debug
google::protobuf::io::Printer::PrintInternal(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >*, char const*)': /usr/include/google/protobuf/io/printer.h:304: undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::StripProto(std::string const&)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/gen.cc:108: undefined reference to
google::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const, bool)' /usr/bin/ld: CMakeFiles/protoc-gen-rpc.dir/gen.cc.o:(.data.rel.ro._ZTVN6google8protobuf8compiler3cpp8muduorpc12RpcGeneratorE[_ZTVN6google8protobuf8compiler3cpp8muduorpc12RpcGeneratorE]+0x28): undefined reference to `google::protobuf::compiler::CodeGenerator::GenerateAll(std::vector<google::protobuf::FileDescriptor const, std::allocator<google::protobuf::FileDescriptor const> > const&, std::string const&, google::protobuf::compiler::GeneratorContext, std::string) const' /usr/bin/ld: CMakeFiles/protoc-gen-rpc.dir/cpp_service.cc.o: in function `google::protobuf::compiler::cpp::muduorpc::ServiceGenerator::ServiceGenerator(google::protobuf::ServiceDescriptor const, std::string const&, int)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:63: undefined reference to `google::protobuf::SimpleItoa(int)' /usr/bin/ld: CMakeFiles/protoc-gen-rpc.dir/cpp_service.cc.o: in functiongoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateDeclarations(google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:70: **undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateInterface(google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:79: u**ndefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::io::Printer::Print(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, char const*)'** /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:112: **undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateStubDefinition(google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:121: u**ndefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateMethodSignatures(google::protobuf::compiler::cpp::muduorpc::ServiceGenerator::StubOrNon, google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:157: undefined reference to
google::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const*, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:158: undefined reference togoogle::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const*, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:159: undefined reference to
google::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:163: undefined reference to `google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::io::Printer::Print(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, char const*)'** /usr/bin/ld: CMakeFiles/protoc-gen-rpc.dir/cpp_service.cc.o: in function
google::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateDescriptorInitializer(google::protobuf::io::Printer, int)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:182: undefined reference togoogle::protobuf::SimpleItoa(int)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:184: undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateImplementation(google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:191: undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateNotImplementedMethods(google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:237: undefined reference to
google::protobuf::SimpleItoa(int)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:238: undefined reference togoogle::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const*, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:239: undefined reference to
google::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:241: undefined reference to `google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateCallMethod(google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:254: undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::SimpleItoa(int)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:267: undefined reference to
google::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:268: undefined reference togoogle::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const*, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:272: undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateGetPrototype(google::protobuf::compiler::cpp::muduorpc::ServiceGenerator::RequestOrResponse, google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:292: undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::io::Printer::Print(std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&, char const*)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:310: undefined reference to
google::protobuf::SimpleItoa(int)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:311: undefined reference togoogle::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const*, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:313: undefined reference to
google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessgoogle::protobuf::compiler::cpp::muduorpc::ServiceGenerator::GenerateStubMethods(google::protobuf::io::Printer*)': /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:333: undefined reference to
google::protobuf::SimpleItoa(int)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:334: undefined reference togoogle::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const*, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:335: undefined reference to
google::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:336: undefined reference to `google::protobuf::compiler::cpp::ClassName(google::protobuf::Descriptor const, bool)' /usr/bin/ld: /home/cyf/cpp-projects/muduo-protorpc/muduo/protorpc2/cpp_service.cc:338: undefined reference to `google::protobuf::io::Printer::Print(std::map<std::string, std::string, std::lessWhat did you expect to see Hope to compile completely and produce library for my own use.
What did you see instead? I try all solutions mentioned from Internet, whether stackoverflow or google. For example: Add -D_GLIBCXX_USE_CXX11_ABI=0, or -lprotoc -lprotobuf -lpthread
or force to link static library libprotobuf.a.
and other unuseful solutions.
Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).
Anything else we should know about your project / environment