Using a simple makefile is the fastest way to compile a small GNOME
application. If you require a more sophisticated build environment, you should
use an autoconf/automake setup, which I will briefly talk about later.
A D V E R T I S E M E N T
The gnome-config Script
The command line to the C compiler for building a GNOME application can
be quite long and would be hard to figure out by hand. So gnome-libs
installs a script to simplify this. It is called gnome-config
and it takes two options, 末cflags and
末libs. The 末cflags option will give you the
compiler flags, needed for the compilation step, and 末libs will give you
the libraries you need to pass to the linker. You also need to pass another
set of arguments to gnome-config. It needs to know what libraries you wish
to use. For our purposes, this is gnome and
gnomeui. So for example to get the compiler flags
for some program using the standard gnome and gnomeui libraries, you would
call "gnome-config 末cflags gnome gnomeui".
A Simple Example Makefile
Now to build a simple makefile, you can use variables
CFLAGS and LDFLAGS and the implicit rules that
at least GNU make supports (others probably do as well, but I'm not familiar
with other makes). So for example let's say you have an application that has
a main.c, main.h, extra.c and extra.h and the executable is called gnome-foo.Now
let's build a small Makefile for this app.