Share via:

How to create a basic GUI using gtkmm in Ubuntu

How to install gtkmm and compile your first GUI program.


Edited: 2017-01-11 02:30

To work with gtkmm in Ubuntu, you will first have to install the package from the official repository, this can be done by typing the following command in terminal:

sudo apt-get install libgtkmm-3.0-dev

After having installed gtkmm, you can try and compile the below example program:


int main(int argc, char *argv[])
  auto app =
    Gtk::Application::create(argc, argv,

  Gtk::Window window;
  window.set_default_size(300, 500);

  return app->run(window);

To compile the above program, copy the code and save it to a YourProgram.cpp, you can replace the "YourProgram" part with whatever name you like.

Open a Terminal and navigate to the directory of your program, then type the following to compile your program:

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

If you try to compile without the extra parameters, you may get a message telling you that gtkmm.h was not found. I.e.:

fatal error: gtkmm.h: No such file or directory compilation terminated.