Compiling GTK+ Applications

A GTK+ installation includes the command gtk-config for identifying where the libraries and header files are installed, including both GTK+ and plain X11 libraries. It can be included directly in the compilation command line by writing

gcc -Wall -g -o sample sample.c `gtk-config --cflags` `gtk-config --libs`
Note the use of back quotes around the gtk-config command. The arguments --cflags and --libs may be placed together in one command: `gtk-config --cflags --libs`.

The GTK+ libraries are also recognised by the autoconf program, which produces a ./configure file used for automatically creating a makefile appropriate for compiling the program.


Previous: Putting things together
Next: Supplementary libraries: GDK, GLIB
Back to index