Skip to content
Advertisement

How to compile opencv with gtk 2.x rather than gtk3.x

I’m using tensorflow 1.4 & qt in ubuntu 16.04. The problem is when I include tensorflow(version: 1.4) and opencv (version: 3.2.0) simultaneously, protobuf is conflicted. The error msg is as follows:

[libprotobuf FATAL external/protobuf_archive/src/google/protobuf/stubs/common.cc:79] This program was compiled against version 2.6.1 of the Protocol Buffer runtime library, which is not compatible with the installed version (3.4.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-O8_xaj/mir-0.26.3+16.04.20170605/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.4.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-O8_xaj/mir-0.26.3+16.04.20170605/obj-x86_64-linux-gnu/src/protobuf/mir_protobuf.pb.cc".)

I learnt from some place that opencv with gtk-3.x will use protobuf 2.6.1 which caused the above problem, and installing opencv with gtk-2.x will not depend on protobuf. And part of the opencv cmake msg is as follows, cmake use gtk 3.x automaticly.

GUI: -- QT: NO -- GTK+ 3.x: YES (ver 3.18.9) -- GThread : YES (ver 2.48.2) -- GtkGlExt: NO -- OpenGL support: NO -- VTK support: NO

And the system gtk information is as follows:

$ pkg-config --modversion gtk+-2.0 $ 2.24.30

Here is the problem.How I can install opencv with gtk 2.x using cmake?

Advertisement

Answer

For me you just need to install the required dependency, which is a version of protobuf compatible with 2.6.1.

A quick search on packages.ubuntu.com shows that the package libprotobuf9v5 provides protocol buffers C++ library and is in version 2.6.1. Just try to install this.

BTW, going back in the past using outdated technologies like GTK+2 is a bad move. If you really want to change your toolkit, selecting it is just a matter of defining the right options on the cmake call. In the toplevel CMakeLists.txt one can easily find WITH_GTK, WITH_GTK2, and WITH_QT options. Enable them on the command line call to cmake, or using cmake-gui And if you’re already using Qt yourself, just rebuild using the Qt backend instead of an old GTK one.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement