libglade, Gtk+, GNU autotools: by example

The Pitch

This is a guide to example code, not a full-fledged tutorial. It might serve as a template for creating a GPL/libglade/Gtk+ distributable application. The GNU autotools are used for all configuration management.

At first, the GNU autotools may seem daunting and like overkill for all but the largest project. Their use becomes essential, however, when compiling all but the simplest hello world program, not to mention installing and distributing software.

Getting Started

Step 1: download the tutorial and build it, following the instructions in README.

The Code

Step 2: Look at these files in your favorite editor.

File Description
configure.ac used by autoconf to generate 'configure' script
Makefile.am used by automake to generate Makefile
src/Makefile.am used by automake to generate Makefile for src/ dir
src/main.c C source code, contains main() function
src/callbacks.c functions called by Gtk+ framework during program execution
src/callbacks.h prototypes for functions in callbacks.c
src/libgladeTest.glade libglade interface definition file -- open it with Glade
src/libgladeTest.gladep Glade project file

Most of the interesting stuff happens in src/libgladeTest.glade. For instance, this is where callbacks get connected to events, causing something useful to happen when you run the program and select Edit -> Preferences. This file is meant to be maintained in Glade (v2.0 or higher). If you are running Fedora Core 2, the RPM package is called 'glade2', and the binary is 'glade-2'. Explore the GUI in Glade.

If you wanted to create a distribution from scratch, it could be done using only the files listed in the table above. Copy these directories and files into a new directory, then run 'touch NEWS README AUTHORS ChangeLog' and 'autoreconf -is'. To create a distribution tarball, run 'make distcheck'.

Where do I start when making my own project?

Step 3: Try starting your own project!

See the "Other Resources" section of this document for some good Hello World examples in both the GNU Autotools and Gtk+/libglade.

Other Resources:


Copyright (C)2004, Adam Monsen


Go Home | Blog | Photos Valid XHTML 1.0! Last Updated $Date: 2005-05-31 20:24:30 -0700 (Tue, 31 May 2005) $
$Revision: 1339 $$Author: adamm $