【问题标题】:How to compile opencv with gtk 2.x rather than gtk3.x如何用 gtk 2.x 而不是 gtk3.x 编译 opencv
【发布时间】:2018-05-10 05:51:18
【问题描述】:

我在 ubuntu 16.04 中使用 tensorflow 1.4 和 qt。问题是当我同时包含 tensorflow(version: 1.4) 和 opencv (version: 3.2.0) 时,protobuf 是冲突的。错误信息如下:

[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 msg如下,cmake自动使用gtk 3.x

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

这就是问题所在。如何使用gtk 2.x 使用cmake 安装opencv?

【问题讨论】:

  • 显示您的 CMakeLists.txt 如何检测 GTK。如果它有类似 SET(GTK_PATH /usr/lib/x86_64-linux-gnu/) 的东西,那么你可以改变那个路径。

标签: c++ linux qt opencv gtk


【解决方案1】:

对我来说,您只需要安装所需的依赖项,它是与 2.6.1 兼容的 protobuf 版本。

packages.ubuntu.com 的快速搜索显示包libprotobuf9v5 提供protocol buffers C++ library 并且版本为2.6.1。尝试安装它。

顺便说一句,使用 GTK+2 等过时的技术回到过去是一个糟糕的举动。如果你真的想改变你的工具包,选择它只是在cmake调用上定义正确的选项。在顶层CMakeLists.txt 中可以轻松找到WITH_GTKWITH_GTK2WITH_QT 选项。在命令行调用cmake 或使用cmake-gui 启用它们如果您自己已经在使用Qt,只需使用Qt 后端而不是旧的GTK 进行重建。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-03
    • 1970-01-01
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 2014-12-25
    • 2011-02-15
    • 2016-01-14
    相关资源
    最近更新 更多