Compiling GTK+ 2.x

I decided to compile GTK+ 2.8.12 — it seemed like a good idea at the time; I had my reasons (this bug and no root access).

So I downloaded the source and some of the dependencies and tried to follow the install guide. Then I hunted out a couple more dependencies. The GTK+ people do provide a lot more help than many projects, so this is not intended as a gripe. But it took me rather longer than I was hoping, just because there’s so much to compile.

The following script worked for me on 2006-02-21. But URLs and version numbers will change, and other systems will be different. So it will quit on the first (inevitable) error (that’s what set -e does). Not the best way of doing things, but maybe seeing the steps explicitly might help someone else. It’s a record for me anyway.


set -e


if [ \! -e "$PREFIX" ] ; then mkdirhier "$PREFIX" ; fi

# Main GTK+-maintained libraries

# Other dependencies

wget ''
# Note that when cairo winges about freetype it might be because fontconfig is missing

# My untar script
untar *tar*

export CPPFLAGS="-I$PREFIX/include"
export LDFLAGS="-L$PREFIX/lib"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
export PATH="$PREFIX/bin:$PATH"
# This one wasn't in the instructions, but I needed it:
export PKG_CONFIG="$PREFIX/bin/pkg-config"
# This one was for "good measure", probably unnecessary:
export LD_RUN_PATH="$PREFIX/lib"

# GAH! This took a while to pin down. I was getting errors about immodules in
# another GTK setup at install time.
unset GTK_PATH
# Checking your distro hasn't tucked anything else bad into your env is a good idea too.

# # GAH must hack makefile for libpng manually!
echo Gah libpng has to be different to the others. Please sort out its Makefile and install it
echo then press enter

# *** Things I got away with
# I had GNU make, libiconv and libintl, you may not
# Cairo must support Xlib backend, so make sure have development libraries for that.
# "locate Intrinsic.h", will tell you if you do (it's what the cairo configure script does)

for a in pkg-config-0.20 jpeg-6b tiff-3.7.4 freetype-2.1.10 fontconfig-2.3.2 cairo-1.0.2 glib-2.8.6 pango-1.10.2 atk-1.10.3 gtk+-2.8.12; do
    cd "$a"
    ./configure --prefix="$PREFIX"
    make install
    cd ..