与libpulsar.so链接时Protobuf版本冲突

问题描述

我正在尝试构建将使用protobuf序列化数据并将其发送到脉冲星消息队列的c ++代码。我已经编写了一个protobuf协议文件自动生成一个c ++代码

我正在以此方式构建代码-

/usr/bin/g++ -g --std=c++11 producer.cc protocol.pb.cc -o test ../protobuf-lib/lib/libprotobuf.so ../pulsar-lib/lib/libpulsar.so -I ../protobuf-lib/include/ -I ../pulsar-lib/include/

build命令成功完成。 但是当我运行可执行文件时,出现错误

[libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.3.0 of the Protocol Buffer runtime library,but the installed version is 2.6.1.  Please update your library.  If you compiled the program yourself,make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification Failed in "/pulsar/pulsar-client-cpp/pkg/rpm/BUILD/apache-pulsar-2.6.1/pulsar-client-cpp/generated/lib/PulSarapi.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():  This program requires version 3.3.0 of the Protocol Buffer runtime library,make sure that your headers are from the same version of Protocol Buffers as your link-time library.  (Version verification Failed in "/pulsar/pulsar-client-cpp/pkg/rpm/BUILD/apache-pulsar-2.6.1/pulsar-client-cpp/generated/lib/PulSarapi.pb.cc".)
Aborted

原因似乎是libpulsar.so在内部与另一个版本(3.3.0)的libprotobuf静态链接,并且在两个lib均在运行时加载时产生冲突。

如何成功链接这两个库?有没有办法使两个库彼此不可见,以免发生冲突?

P.S。我尝试使用与libpulsar使用的相同版本的libprotobuf。它仍然无法正常工作。由于其他一些链接错误,该代码无法编译。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)