0
votes

I'm a beginning C++ programmer and want to use Code::Blocks IDE on Debian based Linux to write some GUI programs.

Therefore I would like to use gtkmm 3.0 with this code:

#include <gtkmm/gtkmm.h>
int main(int argc, char *argv[])
{
  auto app = Gtk::Application::create(argc, argv, "org.gtkmm.examples.base");
  Gtk::Window window;
  window.set_default_size(200, 200);
  return app->run(window);
}

The compiler gives me this error:

fatal error: gtkmm/gtkmm.h: No such file or directory

I followed these steps to install gtkmm:

  1. Installed Code::Blocks and was able to compile non-GUI programs.

  2. Then installed gtkmm-3.0 with synaptic.

  3. In Code::Blocks settings > compiler > compiler settings > other compiler options I set:

    pkg-config --cflags gtk+-3.0

  4. In codeblock settings > compiler> linker settings > other linker settings I set:

    pkg-config --libs gtk+-3.0

  5. When compiling I got the next error in Build log:

    Build file: "no target" in "no project" (compiler: unknown)
    [ 50.0%] g++ -std=c++14 -pthread -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/libdrm -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include  -c /home/meltdown/Documents/C++/GTKmm2019C/t1/t1.cpp -o /home/meltdown/Documents/C++/GTKmm2019C/t1/t1.o
    [100.0%] g++  -o /home/meltdown/Documents/C++/GTKmm2019C/t1/t1 /home/meltdown/Documents/C++/GTKmm2019C/t1/t1.o  -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0  
    /home/meltdown/Documents/C++/GTKmm2019C/t1/t1.cpp:2:10: fatal error: gtkmm/gtkmm.h: No such file or directory
        2 | #include <gtkmm/gtkmm.h>
          |          ^~~~~~~~~~~~~~~
    compilation terminated.
    Process terminated with status 1 (0 minute(s), 0 second(s))
    1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
    

I use a single .cpp file, not a Gtk+ project.

I've tried this and this but no luck. Does anyone know how to set up Code::Blocks and its compiler properly for gtkmm?

1
Do you have gtkmm installed?JaMiT
Yes, installed 3.0 with the package manager.useruser
You might want to list what you've actually done instead of linking to directions. (You could keep the links as references, but let's entertain the possibility that you did not follow the directions perfectly.) In addition, there are two pieces of information that could be useful. First, the compile command. You may need to switch your output tab from "Build messages" to "Build log" to get it. Second, everything that is listed under Project (menu) -> Build Options... (submenu) -> Compiler settings (tab, should be the default) -> Other compiler options (tab).JaMiT
Edited the question.useruser

1 Answers

2
votes

You've asked the IDE to search include directories for the GTK+ package with the command:

`pkg-config --cflags gtk+-3.0`

However, your program uses gtkmm, which is a layer on top of GTK+. You want to broaden the search to encompass the directories for gtkmm:

`pkg-config --cflags gtkmm-3.0`

(This replaces the current entry in the "other compiler options".) Similarly, you'll need to change, under "other linker settings", the library paths to:

`pkg-config --libs gtkmm-3.0`