How to create a basic GUI using gtkmm in Ubuntu

How to install gtkmm and compile your first GUI program.

1746 views

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:

#include 

int main(int argc, char *argv[])
{
  auto app =
    Gtk::Application::create(argc, argv,
      "org.gtkmm.examples.base");

  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.

Tell us what you think:

  1. Generate a GPG key that can be used with KWallet.
  2. How to extract and install FileZilla from tar.bz2 in Ubuntu.
  3. About the problem with using sudo with graphical programs in Linux.
  4. Tutorial showing how to configure a VirtualBox Guest VM with HOST-only and NAT adapter, while using the WWW folder from the HOST OS.
  5. My experience with do-release-upgrade is that it rarely breaks anything, so I would say it is generally a safe and reliable way to upgrade Ubuntu.

More in: Ubuntu