Building applications

This chapter is similar to the "Building applications" chapter in the GTK4 Reference Manual. The same application is built, but gtkmm is used instead of GTK.

An application consists of a number of files:

The binary file

This gets installed in /usr/bin.

A desktop file

The desktop file provides important information about the application to the desktop shell, such as its name, icon, D-Bus name, commandline to launch it, etc. It is installed in /usr/share/applications.

An icon

The icon gets installed in /usr/share/icons/hicolor/48x48/apps, where it will be found regardless of the current theme.

A settings schema

If the application uses Gio::Settings, it will install its schema in /usr/share/glib-2.0/schemas, so that tools like dconf-editor can find it.

Other resources

Other files, such as Gtk::Builder ui files, are best loaded from resources stored in the application binary itself. This eliminates the need for most of the files that would traditionally be installed in an application-specific location in /usr/share.

gtkmm includes application support that is built on top of Gio::Application. In this chapter we'll build a simple application by starting from scratch, adding more and more pieces over time. Along the way, we'll learn about Gtk::Application, Gtk::Builder, resources, menus, settings, Gtk::HeaderBar, Gtk::Stack, Gtk::SearchBar, Gtk::ListBox, and more.

The full, buildable sources for these examples can be found in the examples/book/buildapp directory of the gtkmm-documentation source distribution, or online in the gtkmm-documentation git repository. You can build each example separately by using meson and ninja with the file or by using make with the Makefile.example file. For more information, see the README included in the buildapp directory.