I installed protobuf, with next steps:
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
but when I compile and run my program. I am getting the following error:
/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.
also I have in /usr/lib/x86_64-linux-gnu folder, following files:
./libprotobuf-lite.so.9.0.1
./libprotobuf.so.9.0.1
./libprotobuf.so.9
./libprotobuf-lite.so.9
If I remove them, program will execute properly, however Ubuntu will stuck on boot:
/dev/sda4: clean, xxxxxxx/xxxxxxx files, xxxxxx/xxxxxx blocks
How to solve this problem?
My system is Ubuntu 16.04
I think your code has some other dependencies (e.g., Qt) that are built with 2.6.1 and therefore you can only use 2.6.1 for your build.
But if I delete files libprotobuf* from /usr/lib/x86_64-linux-gnu, my program compiles and run properly, except Ubuntu can't boot
Hmm, then you probably need to update your build scripts to point to the specific version of protobuf you are using. It seems it defaults to 2.6.1 instead of the newest version you installed.
I deleted the files in the /usr/lib/x86_64-linux-gnu to resolve the conflict. Now I cannot boot. @ArslanGapizov how did you fix this problem? Would appreciate your input.
(1)Backup the libprotobuf.so* in /usr/lib/x86_64-linux-gnu ,then compile and run the code,after that ,restore the backup. (2)just delete the libprotobuf.so.9 and libprotobuf.so.9.0.1 and the system boot normally. @ArslanGapizov @mrfarazi
qt5.9 has something related with protobuf 2.6.1;
I just solved this by linking with protobuf static lib rather than shared lib
in project.pro
replace
LIB += -lprotobuf
with
LIBS += /usr/local/lib/libprotobuf.a
I am getting this same error, but the other way around.
I am statically linking a Qt app against protobuf 2.6, and on startup a shared library is throwing an exception because it wants protobuf 3, but thinks only 2.6 is available.
When I try to run it on Ubuntu 17.10, I get an exception on startup.
[libprotobuf FATAL google/protobuf/stubs/common.cc:61] This program requires version 3.0.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 "/build/mir-y44crS/mir-0.28.0+17.10.20171011.1/ obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)
Looking at a stack trace, I see that the source of the exception is a protobuf file called mir_protobuf.pb.cc in libmirprotobuf.so.3
#8 google::protobuf::internal::VerifyVersion (headerVersion=3000000, minLibraryVersion=<optimized out>, filename=0x7f56e740fb00 "/build/mir-y44crS/mir-0.28.0+17.10.20171011.1/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc") at google/protobuf/stubs/common.cc:61
#9 0x00007f56e73dd2bb in mir::protobuf::protobuf_AddDesc_mir_5fprotobuf_2eproto() () from /usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3
#10 0x00007f56e73d0109 in ?? () from /usr/lib/x86_64-linux-gnu/libmirprotobuf.so.3
Deeper in the stack trace I see this is being called by Qt, via libqgtk3.so
#16 0x00007f56f9cde0d9 in _dl_open (file=0x55c572496638 "/usr/lib/x86_64-linux-gnu/qt5/plugins/platformthemes/libqgtk3.so", mode=-2147479551, caller_dlopen=0x7f56f840571c, nsid=-2, argc=<optimized out>, argv=<optimized out>, env=0x7ffe60c11c38) at dl-open.c:660
...
#23 0x00007f56f83ef068 in QFactoryLoader::instance(int) const () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
protobuf 3 is installed by default on Ubuntu 17.10
libmirprotobuf3/artful,now 0.28.0+17.10.20171011.1-0ubuntu1 amd64 [installed,automatic]
libprotobuf-dev/artful,now 3.0.0-9ubuntu5 amd64 [installed]
libprotobuf-lite10/artful,now 3.0.0-9ubuntu5 amd64 [installed,automatic]
libprotobuf10/artful,now 3.0.0-9ubuntu5 amd64 [installed,automatic]
My app is statically linking against protobuf 2.6, but it seems this is interfering with libmirprotobuf.so.3.
How can I tell libmirprotobuf.so.3 that libprotobuf-3 is available on the system, and to bypass the fact my app has statically linked libprotobuf-2.6?
Is it possible to run my app on Ubuntu 17.10?
@skebanga I don't think there's any easy way to have multiple protobuf library versions coexist in the same binary, even if one is statically linked and the other is dynamically linked. I would guess the easiest solution in your case would be to avoiding statically linking against protobuf 2.6, and instead just use the protobuf 3.0 provided by Ubuntu. That way everything will consistently use 3.0 only.
I had faced similar problems with a QT project. The main reason here is that the pre-built binaries of QT and QT creator are dependent on 2.6v of protobuf. Hence if you want to have a QT project run with 2 versions of protobuf, v3.x must be installed as static library and install it in /usr/local/lib. Now you have to build QT from sources on top of the v3.x.
I solved my problem by keeping both the versions in the above way.
Don't remove / purge the older i.e 2.6v which comes as a part of system as many libraries like mirprotobuf and opencv depend upon that version.
Any application or libraries that depend upon protobuf have to be rebuilt.
In my case, I remove the environment variable about libprotobuf at etc/bash.bshrc
from
export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libprotobuf.so.9
to
export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libstdc++.so.6
And, I solved.
@xfxyjwf The reason for ubuntu can not boot is that, libprotobuf.so.9 (which is protobuf 2.6.10 is needed by gtk-3.0 and so that opencv will relias on it. Also all your gnome will relias on it.
Eventually, it will got a conflict when you link a protobuf3.6.1 program
Most helpful comment
qt5.9 has something related with protobuf 2.6.1;
I just solved this by linking with protobuf static lib rather than shared lib
in project.pro
replace
LIB += -lprotobuf
with
LIBS += /usr/local/lib/libprotobuf.a