Headers and Linking
| Chapter 3. Basics |

## Headers and Linking

Although we have shown the compilation command for the simple example, you really should use the Meson build system. The examples used in this book are included in the gtkmm-documentation package, with appropriate build files, so we won't show the build commands in future. The `README` file in gtkmm-documentation describes how to build the examples.

To simplify compilation, we use `pkg-config`, which is present in all (properly installed) gtkmm installations. This program 'knows' what compiler switches are needed to compile programs that use gtkmm. The `--cflags` option causes `pkg-config` to output a list of include directories for the compiler to look in; the `--libs` option requests the list of libraries for the compiler to link with and the directories to find them in. Try running it from your shell-prompt to see the results on your system.

However, this is even simpler when using the `dependency()` function in a `meson.build` file with Meson. For instance:

    gtkmm_dep = dependency('gtkmm-3.0', version: '>= 3.24.0')

This checks for the presence of gtkmm and defines `gtkmm_dep` for use in your `meson.build` files. For instance:

    exe_file = executable('my_program', 'my_source1.cc', 'my_source2.cc',
      dependencies: gtkmm_dep,
      win_subsystem: 'windows',
    )

gtkmm-3.0 is the name of the current stable API. There was an older API called gtkmm-2-4 which installs in parallel when it is available. There were several versions of gtkmm-2.4, such as gtkmm 2.10 and there are several versions of the gtkmm-3.0 API. Note that the API name does not change for every version because that would be an incompatible API and ABI break. There is a newer gtkmm-4.0 API which installs in parallel with gtkmm-3.0 without affecting existing applications.

If you start by experimenting with a small application that you plan to use just for yourself, it's easier to start with a `meson.build` similar to the `meson.build` files in the Building applications chapter.

If you use the older Autotools build system, see also the GNU site. It has more information about autoconf and automake. There are also some books describing Autotools: "GNU Autoconf, Automake, and Libtool" by Gary Vaughan et al. and "Autotools, A Practitioner's Guide to GNU Autoconf, Automake, and Libtool" by John Calcote.

Chapter 3. Basics |  | Widgets