Reputation: 157
OS: Debian 9.1
Compiler: gcc (Debian 6.3.0-18)
GTK+ Version: 3.22.11-1
Gtkmm Version: 3.22.0-1
Hello all, I've been dealing with a pesky issue with Gtkmm 3.22.0-1 build the simple application given on the tutorial. I'm building the project using CMake, and I get the following error:
error: 'Gtk::Application' has not been declared
Gtk::Application::create(argc, argv,
(recipe for target failed, etc...)
This error comes as a result of the standard "simplest program" for Gtkmm.
#include <iostream>
#include<gtkmm.h>
int main(int argc, char* argv[])
{
auto app =
Gtk::Application::create(argc, argv,
"org.gtkmm.examples.base");
Gtk::Window win;
win.set_default_size(200, 200);
return app->run(win);
}
From research I can say that this error was common near the release of Gtkmm 3 as Gtk::Application was not implemented until Gtkmm 3.4 (around 2012). The example given above is for Gtkmm 3 from the GNOME documentation site (link above).
I have installed Gtkmm-3-dev, pkg-config returns all the right flags and directories, and the CMakeLists.txt includes the following:
find_package(PkgConfig REQUIRE)
pkg_check_modules(GTKMM gtkmm-3)
link_directories( ${GTKMM_LIBRARY_DIRS} )
include_directories( ${GTKMM_INCLUDE_DIRS} )
...
target_link_libraries(proj ${GTKMM_LIBRARIES} )
Where 'proj' is the name of my project. I'm running Debian GNU/Linux 9.1 (stretch). The output of pkg-config gtkmm-3 --cflags:
-pthread -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/atkmm-1.6 -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
I cannot find any recent posts related to this problem, and my next option is to sift through the Gtkmm API docs in search of an answer. I found that there is a Gio::Application that might work in a similar way, but I have not explored this fully. Any help is greatly appreciated, thanks.
Sam
Upvotes: 1
Views: 1570
Reputation: 157
Problem solved, the issue was with CMake not finding Gtkmm-3 because the package is titled "gtkmm-3.0". So this line in CMakeLists.txt:
pkg_check_modules(GTKMM gtkmm-3)
Is supposed to be:
pkg_check_modules(GTKMM gtkmm-3.0)
Thanks to JohnKoch for helping resolve this issue.
Upvotes: 1