1

I am trying to build c++ code that will use protobuf to serialize the data and send to pulsar message queue. I have written a protobuf protocol file and autogenerated a c++ code.

I am building the code as this -

/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/

The build command completes successfully. But when I run the executable, I get error

[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, 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".)
Aborted

The reason seems to be that libpulsar.so internally statically links with libprotobuf of a different version (3.3.0) and creates a conflict when both libs are loaded at runtime.

How can I successfully link with both these libraries ? Is there a way to make the two libraries invisible to each other so that the conflict doesn't happen?

P.S. I have tries using the same version of libprotobuf as used by libpulsar. It still won't work. The code does not compile due to some other linker errors.

punekr12
  • 653
  • 2
  • 7
  • 14

0 Answers0