我正在尝试编译使用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。 &&制作:
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上的官方Wiki页面即可。

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

10-12 19:31