Protocol buffers 使用protobuff编译qtcreator问题
我试图用protobuf的新版本编译我的代码(目前它是用自定义版本编译的,我想用ubuntu通过apt get附带的版本编译它) 在项目设置中,我添加了Protocol buffers 使用protobuff编译qtcreator问题,protocol-buffers,qt-creator,ubuntu-16.04,Protocol Buffers,Qt Creator,Ubuntu 16.04,我试图用protobuf的新版本编译我的代码(目前它是用自定义版本编译的,我想用ubuntu通过apt get附带的版本编译它) 在项目设置中,我添加了-lprotobuf .obj/Test.pb.o: In function `test_ns::protobuf_AssignDesc_Test_2eproto()': <<path to file>>/Test.pb.cc:115: undefined reference to `google::protobuf::D
-lprotobuf
.obj/Test.pb.o: In function `test_ns::protobuf_AssignDesc_Test_2eproto()':
<<path to file>>/Test.pb.cc:115: undefined reference to `google::protobuf::DescriptorPool::FindFileByName(std::string const&) const'
我可以看到,在试图定位文件“Test.proto”时产生的错误,但它存在于另一个目录中,protoc命令使用它生成Test.pb.cc和Test.pb.h文件,这就是原因,ubuntu提供的protobuff使用不同的ABI编译而成,在我们的项目中匹配ABI解决了这个问题
void protobuf_AssignDesc_Test_2eproto() {
protobuf_AddDesc_Test_2eproto();
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"Test.proto");