Compiling Hello World Programs
The compile command is:
gcc -wall -g helloworld.c -o helloworld `pkg-config --cflags gtk -2.0` /` pkg-config --LIBS GTK -2.0`
Use program PKG-Config, you can get from www.freeDesktop.org. This program reads the file .PC to determine the compilation option you need to compile the GTK program. PKG-Config - CFLAGS GTK -2.0 lists the incrude directory, PKG-Config --Libs GTK -2.0 lists the compilation connection library, can also be combined, like this: pkg-config --cflags --Libs GTK -2.0 .
Note that "command replacement" is used in the above compile command. Command Substitution enables the output of a command to replace it in another command.
Library often use:
GTK library (-lgtk), component library, based on GDK.
GDK library (-lgdk), XLIB library package (Wrapper).
GDK-PIXBUF library (-LGDK_PIXBUF), image processing library.
PANGO library (-LPANGO), internationalization.
GOBJECT library (-lgObject) contains a type system of GTK.
GModule library (-lgmodule), dynamic running library.
GLIB library (-lglib) contains various functions; only g_print () is used in this example. GTK is based on GLIB, so you always need this library. See the chapter of Glib for details.
XLIB library (-LX11), GDK is used.
XEXT library (-LXEXT), contains shared memory bitmaps and other x extensions.
Math library (-LM), math library.