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.
This is an extremely simple makefile, but it should get you started.
Using automake/autoconf
Using automake and autoconf is really beyond the scope of this document, read the info pages if you have them installed with gnome-help-browser.
There is now an example application which can help you get started with
autoconf/automake, the internationalization setup, and other build issues, as
well as serve as a good hello world example.