Undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]

前端 未结 3 1692
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 07:11

I\'m trying to build simple test application with Protocol Buffers 2.6.1 and GNU GCC 5.1.0 (on Ubuntu 14.10) and I get following errors:

/home/ragnar/cpp-too         


        
3条回答
  •  日久生厌
    2020-12-03 07:39

    I had similar problem as

    writeProto.cpp:(.text+0x2a8): undefined reference to `google::protobuf::internal::VerifyVersion(int, int, char const*)'
    writeProto.cpp:(.text+0x308): undefined reference to `tutorial::AddressBook::AddressBook()'
    writeProto.cpp:(.text+0x3a2): undefined reference to `google::protobuf::Message::ParseFromIstream(std::istream*)'
    writeProto.cpp:(.text+0x463): undefined reference to `google::protobuf::Message::SerializeToOstream(std::ostream*) const'
    writeProto.cpp:(.text+0x4b4): undefined reference to `google::protobuf::ShutdownProtobufLibrary()'
    writeProto.cpp:(.text+0x4c8): undefined reference to `tutorial::AddressBook::~AddressBook()'
    writeProto.cpp:(.text+0x515): undefined reference to `tutorial::AddressBook::~AddressBook()'
    

    I wrote this on the command line and now my code is working.

    c++ writeProto.cpp addressbook.pb.cc `pkg-config --cflags --libs protobuf`
    

提交回复
热议问题