Cabeceras y enlazado

Although we have shown the compilation command for the simple example, you really should use the automake and autoconf tools, as described in "Autoconf, Automake, Libtool", by G. V. Vaughan et al. 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. You'll just need to find the appropriate directory and type make.

Para simplificar la compilación, se usa pkg-config, que está presente en todas las instalaciones correctas de gtkmm. Este programa «sabe» qué opciones de compilación son necesarias para compilar los programas que usan gtkmm. La opción --cflags hace que pkg-config devuelva la lista de carpetas en las que el compilador buscará los archivos de cabecera; la opción --libs solicita la lista de bibliotecas a las que el compilador enlazará y las carpetas en las que encontrarlas. Intente ejecutarlo desde su intérprete de comandos para ver los resultados en su sistema.

However, this is even simpler when using the PKG_CHECK_MODULES() macro in a standard configure.ac file with autoconf and automake. For instance:

PKG_CHECK_MODULES([MYAPP], [gtkmm-4.0 >= 4.8.0])
This checks for the presence of gtkmm and defines MYAPP_LIBS and MYAPP_CFLAGS for use in your Makefile.am files.

gtkmm-4.0 is the name of the current stable API. There are older APIs called gtkmm-2.4 and gtkmm-3.0 which install in parallel when they are available. There are 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 might be a future gtkmm-5.0 API which would install in parallel with gtkmm-4.0 without affecting existing applications.

Note that if you mention extra modules in addition to gtkmm-4.0, they should be separated by spaces, not commas.

The GNU site has more information about autoconf and automake.

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