如何使用gtk 2.x而不是gtk3.x编译opencv [英] How to compile opencv with gtk 2.x rather than gtk3.x
问题描述
我正在使用tensorflow 1.4& ubuntu 16.04中的qt.问题是当我同时包含tensorflow(版本:1.4)和opencv(版本:3.2.0)时,protobuf发生冲突.错误消息如下:
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".)
[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".)
我从某个地方了解到,使用gtk-3.x
的opencv将使用protobuf 2.6.1
,这会导致上述问题,并且使用gtk-2.x
安装opencv不会依赖于protobuf.而部分opencv cmake消息如下,cmake自动使用gtk 3.x
.
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
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
系统gtk信息如下:
$ pkg-config --modversion gtk+-2.0
$ 2.24.30
$ pkg-config --modversion gtk+-2.0
$ 2.24.30
这是问题所在.如何使用cmake
在gtk 2.x
中安装opencv?
Here is the problem.How I can install opencv with gtk 2.x
using cmake
?
推荐答案
对我来说,您只需要安装必需的依赖项,该依赖项是与2.6.1兼容的protobuf
版本.
For me you just need to install the required dependency, which is a version of protobuf
compatible with 2.6.1.
在 packages.ubuntu上进行快速搜索.com 显示软件包libprotobuf9v5
提供了protocol buffers C++ library
,并且版本为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.
顺便说一句,使用GTK + 2之类的过时技术回溯过去是一个错误的举动.如果您确实要更改工具包,则选择它只是在cmake
调用中定义正确的选项.在顶级CMakeLists.txt
中,可以轻松找到WITH_GTK
,WITH_GTK2
和WITH_QT
选项.在命令行调用cmake
或使用cmake-gui
启用它们,如果您已经在使用Qt,只需使用Qt后端而不是旧的GTK后端进行重建.
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.
这篇关于如何使用gtk 2.x而不是gtk3.x编译opencv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!