冲突Protobuf版本

时间:2017-04-17 15:56:58

标签: c++ linux protocol-buffers

系统:Ubuntu 16.04

我安装了protobuf,后续步骤:

sudo apt-get install autoconf automake libtool curl make g++ unzip
wget https://github.com/google/protobuf/releases/download/v3.2.0/protobuf-cpp-3.2.0.tar.gz
tar -xvf protobuf-cpp-3.2.0.tar.gz
cd protobuf-3.2.0
./autogen.sh
./configure
make
make check
sudo make install
sudo ldconfig

但是当我尝试编译我的程序时。我收到以下错误

/home/arslan/www/src/main/build-controlpanel-Desktop_Qt_5_8_0_GCC_64bit-Debug/controlpanel
[libprotobuf FATAL google/protobuf/stubs/common.cc:78] This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.2.0).  Contact the program author for an update.  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 "/build/mir-pkdHET/mir-0.21.0+16.04.20160330/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():  This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.2.0).  Contact the program author for an update.  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 "/build/mir-pkdHET/mir-0.21.0+16.04.20160330/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
The program has unexpectedly finished.

我也在/usr/lib/x86_64-linux-gnu文件夹中,有以下文件:

./libprotobuf-lite.so.9.0.1
./libprotobuf.so.9.0.1
./libprotobuf.so.9
./libprotobuf-lite.so.9

如果我删除它们,程序将正确执行,但Ubuntu将停留在启动

/dev/sda4: clean, xxxxxxx/xxxxxxx files, xxxxxx/xxxxxx blocks

如何解决这个问题?

2 个答案:

答案 0 :(得分:2)

qt5.9与protobuf 2.6.1有关;

我刚刚通过链接protobuf静态lib而不是共享lib来解决这个问题

在project.pro

替换

  

LIB + = -lprotobuf

  

LIBS + = /usr/local/lib/libprotobuf.a

答案 1 :(得分:0)

看起来你将你编写的protobuf与OS的protobuf混合在一起。尝试强制所有protoclibprotobuf的路径。或者,如果可以,请从Ubuntu卸载protobuf。

相关问题