Lately I’ve been writing a lot of codes using gtkmm 3.0. The latest stable branch is 2.4, but this is based on GTK+ 2… and I really want to use GTK+ 3. Why? Because GTK+ 3 uses cairo for it’s native drawing API, and cairo is sweet. gtkmm uses cairomm, which is even sweeter. So here are my notes on getting gtkmm-3 built and installed for Ubuntu 11.04. I’ve written a shell script to do all the work, but I’ll go through it section by section to explain what’s going on.
Setup
Traditionally /usr/
is used for normal system stuff /usr/local
is for experimental stuff (it’s essentially the same as /usr
but it makes it easy to find and remove stuff after it breaks your system). However, since I originally was developing with the unstable Gtkmm branch in Ubuntu 10.04, which didn’t even have a package for GTK+ 3 in the repositories, I started installing things into my home directory… since it’s just for testing anyway. Therefore, I create a directory $HOME/Codes/devroot
(for development root filesystem) where I install all the “unstable” packages I’m using, or where I practice-install the programs/libraries I’m writing.
I also make a directory $HOME/Codes/cpp/gnome
where I download all the source tarballs and do the building.
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/bash cd $HOME export BASE=$HOME/Codes/devroot export PATH=$BASE/bin:$PATH export LD_LIBRARY_PATH=$BASE/lib:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$BASE/lib/pkgconfig:$PKG_CONFIG_PATH export XDG_DATA_DIRS=$BASE/share:$XDG_DATA_DIRS export ACLOCAL_FLAGS="-I $BASE/share/aclocal $ACLOCAL_FLAGS" mkdir -p $BASE mkdir -p Codes/cpp/gnome cd Codes/cpp/gnome |
Next I export some variables containing the versions of the unstable packages I’m using. This is so that I can quickly update the script for future installations and things.
15 16 17 18 19 20 | export MM_COMMON_VER=0.9.5 export GLIBMM_VER=2.28.1 export ATKMM_VER=2.22.5 export PANGOMM_VER=2.28.2 export CAIROMM_VER=1.1.10 export GTKMM_VER=3.0.1 |
Then I download all the source tarballs
22 23 24 25 26 27 | wget http://ftp.acc.umu.se/pub/GNOME/sources/mm-common/0.9/mm-common-$MM_COMMON_VER.tar.gz wget http://ftp.acc.umu.se/pub/GNOME/sources/glibmm/2.28/glibmm-$GLIBMM_VER.tar.gz wget http://ftp.acc.umu.se/pub/GNOME/sources/atkmm/2.22/atkmm-$ATKMM_VER.tar.gz wget http://ftp.acc.umu.se/pub/GNOME/sources/pangomm/2.28/pangomm-$PANGOMM_VER.tar.gz wget http://ftp.acc.umu.se/pub/GNOME/sources/gtkmm/3.0/gtkmm-$GTKMM_VER.tar.gz wget http://cairographics.org/snapshots/cairomm-$CAIROMM_VER.tar.gz |
And extract them all into $HOME/Codes/cpp/gnome
(currently PWD
).
29 30 31 32 33 34 | tar xvzf mm-common-$MM_COMMON_VER.tar.gz tar xvzf glibmm-$GLIBMM_VER.tar.gz tar xvzf atkmm-$ATKMM_VER.tar.gz tar xvzf pangomm-$PANGOMM_VER.tar.gz tar xvzf gtkmm-$GTKMM_VER.tar.gz tar xvzf cairomm-$CAIROMM_VER.tar.gz |
Then we start installing the packages in the appropriate order. There are a few ugly things that we have to do in the process though.
36 37 38 39 40 41 42 43 44 45 | cd mm-common-$MM_COMMON_VER ./configure --prefix=$BASE make -j6 make install cd .. cd glibmm-$GLIBMM_VER ./configure --prefix=$BASE make -j6 make install |
The first ugly thing is that the glibmm package doesn’t install the doctool perl script like it should… so we have to do that manually:
46 47 | mkdir -p $BASE/share/glibmm-2.4/doctool/ cp docs/doc-install.pl $BASE/share/glibmm-2.4/doctool/ |
Then we continue installing the libraries
48 49 50 51 52 53 54 55 56 57 | cd .. cd atkmm-$ATKMM_VER ./configure --prefix=$BASE make -j6 make install cd .. cd pangomm-$PANGOMM_VER ./configure --prefix=$BASE |
The second ugly thing we have to do is move libfreetype.la
to where libtool can find it. I’m not sure why it can’t find this specific library but for whatever reason, even after setting LD_LIBRARY_PATH
it always looks in /usr/lib. So I just pretend like no ones watching and create a symlink.
58 | sudo ln -s /usr/lib/x86_64-linux-gnu/libfreetype.la /usr/lib/ |
And everything after that goes pretty normally.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | make -j6 make install cd .. cd cairomm-$CAIROMM_VER ./configure --prefix=$BASE make -j6 make install cd .. cd gtkmm-$GTKMM_VER ./configure --prefix=$BASE make -j6 make install cd .. |