Hlavičkové soubory a linkování
Ačkoliv jsme si ukázali na jednoduchém příkladu příkaz pro kompilaci, měli byste ve skutečnosti používat nástroje automake a autoconf, jak je to popsáno v „Autoconf, Automake, Libtool“ od G. V. Vaughana a kol. Příklady uváděné v této knize jsou zahrnuté v balíčku gtkmm-documentation včetně příslušných souborů pro sestavení, takže příkazy pro sestavení již nadále nebudeme uvádět. Stačí vám jen najít příslušnou složku s příkladem a napsat make.
Pro zjednodušení kompilace používáme pkg-config, který najdete ve všech (správně nainstalovaných) instalacích gtkmm. Tento program „zná“ přepínače, které jsou zapotřebí ke kompilaci programu, který používá gtkmm. Přepínač --cflags způsobí, že pkg-config vypíše seznam složek, ve kterých kompilátor hledá hlavičkové soubory, a přepínač --libs zažádá o seznam knihoven, které má kompilátor přilinkovat, a o složky, ve kterých je má hledat. Zkuste si to spustit ručně v shellu, abyste viděli výsledky pro váš systém.
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])
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.