Search code examples
c++gtkmm

Error: GTKMM 3.0 compiling error


I have this error when compiling my first gtkmm project.

gtkmmgui.cpp:2:10: fatal error: gtkmm-3.0: No such file or directory

I also tried this:

g++ gtkmmgui.cpp `pkg-config --cflags --libs gtkmm3.0`

but it still doesn't work.

Is this because of wrong #include directory?

Source:

#include <iostream>
#include <gtkmm-3.0>

int main() {
    Gtk::Main kit(argc, argv);
    Gtk::Window window;
    Gtk::Window::run(window)
    return 0;
}

Solution

  • There should be nothing like

    #include "gtkmm-3.0"
    

    in your source.

    Typically all includes look like:

    #include <gtkmm/application.h>
    #include <gtkmm/window.h>
    

    You should provide also your source code here, because the error is something there! But please reduce it to the minimum where we can see your problem. Please never post all your code which is not related to the problem you ask for.

    You also can check if your configuration of gtkmm is correct by simply looking in the output of you pkg-config command. Simply enter it on the command line:

    > pkg-config gtkmm-3.0 --cflags
    

    It should be something like:

    -I/usr/include/gtkmm-3.0 -I/usr/lib64/gtkmm-3.0/include < a lot more >
    

    EDIT: Your example code is broken in so many parts! Please read the manual of gtkmm!

    The following works:

    #include <gtkmm/window.h>
    #include <gtkmm/main.h>
    
    
    int main(int argc, char *argv[]) {
        Gtk::Main kit(argc, argv);
        Gtk::Window window;
        kit.run(window);
        return 0;
    }
    

    compiled and linked with:

    g++ `pkg-config gtkmm-3.0 --cflags --libs` main.cpp