Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Protocol buffers 使用protobuff编译qtcreator问题_Protocol Buffers_Qt Creator_Ubuntu 16.04 - Fatal编程技术网

Protocol buffers 使用protobuff编译qtcreator问题

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

我试图用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::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");