Saturday, 25 January 2014

Compiling GTK+ 2 on Amazon Linux

It's the usual story, I need some small seemingly simple library installed - in this case UFRaw so I could get ImageMagick to convert raw camera images, and I end up spending hours trying to get a dependency built - this time it was GTK+ 2, which has a load of dependencies which themselves aren't too easy to build.

So I've had to do this a couple of times now, and each time, I completely forget how to do it and spend ages fumbling with the wrong libraries - hence the write up.

I install everything into /usr/local/. If you want to put it somewhere else just make sure to update the envars as well as the configure prefix.

Tip: You'll need root privileges to run "make install"

   1. Set up environment variables so pkg-config can find the libs we're installing.
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/local/lib
   2. Install dependencies that are available in the yum repo.
yum install libffi-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel fontconfig-devel pango-devel gcc gettext

   3.  Make a directory to hold all the sources
mkdir ~/gtk_sources

   4. Install glib 2.38. As of writing, this is the most recent version. ATK needs at least 2.31,and this isn't available in the repos.
cd ~/gtk_sources
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.38/glib-2.38.2.tar.xz
tar -xJf glib-2.38.2.tar.xz
cd glib-2.38.2
./configure --prefix=/usr/local
make
make install

   5. Install ATK
cd ~/gtk_sources
wget http://ftp.gnome.org/pub/GNOME/sources/atk/2.10/atk-2.10.0.tar.xz
tar -xJf atk-2.10.0.tar.xz
cd atk-2.10.0
./configure --prefix=/usr/local
make
make install


   6. Install gdk-pixbuf
cd ~/gtk_sources
wget http://ftp.gnome.org/pub/GNOME/sources/gdk-pixbuf/2.29/gdk-pixbuf-2.29.3.tar.xz
tar -xJf gdk-pixbuf-2.29.3.tar.xz
cd gdk-pixbuf-2.29.3
./configure --prefix=/usr/local
make
make install

   7.  Install GTK+ 2. (2.24.22)
cd ~/gtk_sources
wget http://ftp.gnome.org/pub/gnome/sources/gtk+/2.24/gtk+-2.24.22.tar.xz
tar -xJf gtk+-2.24.22.tar.xz
cd gtk+-2.24.22
./configure --prefix=/usr/local
make
make install


Hopefully all works and GTK is installed.


I've tested this on a clean install of Amazon Linux at the time of posting so should be good, but if anyone notices a mistake please comment.