【发布时间】:2016-04-01 15:29:40
【问题描述】:
我在链接 protobuf 库时遇到问题。
/tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x444): 未定义引用
google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x4a9): undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x4c4): 未定义的引用google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x4de): undefined reference togoogle::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x502): 未定义的引用google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x53c): more undefined references togoogle::protobuf::internal::kEmptyString' 跟随 /tmp/ccKgczB9.o:TickData.pb.cc:(.text$_ZN6google8protobuf8internal10WireFormat16VerifyUTF8StringEPKciNS2_9OperationE[__ZN6google8protobuf8internal10WireFormat16VerifyUTF8StringEPKciNS2_9OperationE]+0x1b): 未定义的引用 `google::protobuf::internal::WireFormat::VerifyUTF8StringFallback(char const*, int, google::protobuf::internal::WireFormat::Operation)' collect2:错误:ld 返回 1 个退出状态
使用语言:C++ Protobuf 版本:2.6.1
我已经尝试过以下链接,但没有成功:
Can't compile example from google protocol buffers
和
Undefined reference to google::protobuf::internal::empty_string_[abi:cxx11]
我是 C++ 新手。我也尝试过使用 -std=c++11 编译 protobuf 但仍然是同样的错误。
任何指针都会有所帮助。
【问题讨论】:
-
请显示您使用的编译器命令行。 (我的猜测是它缺少
-lprotobuf标志。) -
g++ -g -L"/cygdrive/d/Softwares/protobuf-2.6.1/src/.libs" ../proto/TickData.pb.cc main.cpp -std=c+ +11 -lprotobuf
标签: c++ c++11 protocol-buffers