c++ - 更正 gtk、gtkmm 和 opencv 的 CMakeLists.txt 文件

标签 c++ opencv cmake gtk gtkmm

我正在尝试编译一个使用 gtkmm 和 opencv 的 GTK2 程序。我用命令行 g++ 试了一下:

g++ main.cpp -o bla `pkg-config --cflags --libs gtkmm-2.4 opencv`

抛出与下面输出相同的错误。

我用 cmake 和下面的 CMakeLists.txt 文件试过了:

project (gtk-test)
cmake_minimum_required (VERSION 2.4)

find_package (PkgConfig REQUIRED)
pkg_check_modules (GTK2 REQUIRED gtk+-2.0)

include_directories (${GTK2_INCLUDE_DIRS})
link_directories (${GTK2_LIBRARY_DIRS})
add_executable (gtk-test main.c)
add_definitions (${GTK2_CFLAGS_OTHER})
target_link_libraries (gtk-test ${GTK2_LIBRARIES})

制作。 && 制作:

CMake Warning (dev) at CMakeLists.txt:6 (link_directories):
This command specifies the relative path

   $GTKMM_LIBRARY_DIRS}

  as a link directory.

  Policy CMP0015 is not set: link_directories() treats paths relative to the
  source dir.  Run "cmake --help-policy CMP0015" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done
-- Build files have been written to: /Users/alefveld/Downloads/gtkcv
[ 25%] Building CXX object CMakeFiles/bla.dir/MainWindow.cpp.o
In file included from /Users/alefveld/Downloads/gtkcv/MainWindow.cpp:1:
In file included from /Users/alefveld/Downloads/gtkcv/MainWindow.hpp:12:
In file included from /usr/local/include/gtkmm-2.4/gtkmm/window.h:7:
In file included from /usr/local/include/glibmm-2.4/glibmm.h:87:
In file included from /usr/local/include/glibmm-2.4/glibmm/thread.h:49:
In file included from /usr/local/include/glibmm-2.4/glibmm/error.h:23:
In file included from /usr/local/include/glibmm-2.4/glibmm/exception.h:25:
/usr/local/include/glibmm-2.4/glibmm/ustring.h:267:13: error: expected ';' at
      end of declaration list
  ~ustring() noexcept;
            ^
            ;
/usr/local/include/glibmm-2.4/glibmm/ustring.h:881:48: warning: deleted function
      definitions are a C++11 extension [-Wc++11-extensions]
  FormatStream(const ustring::FormatStream&) = delete;
                                               ^
/usr/local/include/glibmm-2.4/glibmm/ustring.h:882:59: warning: deleted function
      definitions are a C++11 extension [-Wc++11-extensions]
  FormatStream& operator=(const ustring::FormatStream&) = delete;
                                                          ^
/usr/local/include/glibmm-2.4/glibmm/ustring.h:894:18: error: expected ';' at
      end of declaration list
  ~FormatStream() noexcept;
                 ^
                 ;
/usr/local/include/glibmm-2.4/glibmm/ustring.h:1273:45: warning: deleted

等等。我在这里错过了什么?任何帮助将不胜感激。如何一次性编译 Gtk/gtkmm 和 opencv?

最佳答案

GTKmm 和 GTK 是两个不同的东西。 GTKmm 是 GTK 的 C++ 绑定(bind),因此 GTKmm 依赖于 GTK 库。

对于 CMake 和 GTKmm,请查看 using CMake with GTKmm 上的官方维基页面。 .

关于c++ - 更正 gtk、gtkmm 和 opencv 的 CMakeLists.txt 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35879749/

相关文章:

c++ - Qt - 返回 qint32 数组的数组

c++ try and catch 时的返回值

c++ - Opencv 3.0 通过蓝牙广播数据

c++ - 使用 CMake 和 C++ 运行 mysql-connector?

bash - 在我的 Ubuntu 安装中,VERBOSE 环境变量在哪里以及为什么设置为 "no"?

C++ timer_create() 不创建新线程

python OpenCV - 将 alpha channel 添加到 RGB 图像

python - 在 OpenCV 中查找子像素中的轮廓点

c++ - findHomography 在 OpenCV 3.0 中不起作用

c++ - 从另一个 CMakeLists.txt 将变量读入 cmake