在链接protobuf库时,我面临一个问题。
/tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x444):未定义的对
google::protobuf::internal::kEmptyString' /tmp/ccKgczB9.o:TickData.pb.cc:(.text+0x4a9): undefined reference to的引用o:TickData.pb.cc:(.text$_ZN6google8protobuf8internal10WireFormat16VerifyUTF8StringEPKciNS2_9OperationE__ZN6google8protobuf8internal10WireFormat16VerifyUTF8StringEPKciNS2_9OperationE+0x1b):未定义的对`google::protobuf::internal::WireFormat::VerifyUTF8StringFallback(char const*的引用int,google::protobuf::internal::WireFormat::Operation)‘collect2: error: ld返回1退出状态
使用的语言: C++ Protobuf版本: 2.6.1
我已经在下面的链接上尝试过一些东西,但是它没有成功:
Can't compile example from google protocol buffers
和
我是C++的新手。我也尝试过使用-std=c++11编译原型,但仍然是相同的错误。
任何指示都会有帮助。
发布于 2016-04-05 15:07:16
我确实想出了出路。
我需要首先为-c使用g++选项并生成.o文件。同样,必须单独使用-o选项来生成可执行文件。
如下所示:
g++ -c -L/cygdrive/d/Workspace/CPP/Practice/.-c/proto/TickData.pb.cc main.cpp -std=c++11 -lprotobuf
g++ -g -Wall TickData.pb.o main.o -o MarketData.o -std=c++11 -lprotobuf
https://stackoverflow.com/questions/36360188
复制相似问题