Monday, January 21, 2013

Building GIMP 2.9.1 from source on Linux Mint 13

On Open Source Photography group on Google+ https://plus.google.com/u/0/communities/110647644928874455108 goes discussion: how nobody is providing deb for GIMP 2.9.1 and you can download installer for Mac or Windows, for example from here http://www.partha.com/. I guess most of Linux users are capable of compiling and building software on its own and that could be reason. There are distros like Gentoo Linux where building packages from source is common and in that way your binaries will be best match for your hardware. On the other side building GIMP is not so easy, for example one of dependencies is Gtk+ and that one is never easy to build. Since I am doing programming for living, I decided to help and write tutorial how to build GIMP 2.9.1 from source. Before I start, GIMP 2.9.1 is unstable development release, it is not intended for final user, it is slow and if you still want to build it do that in VM, place build environment in KVM or VBox. On positive side - yes it can handle 16 bit integer channel.
Starting point for me was Compiling Gimp 2.9.x on PCLinuxOS KDE4 2012.02 http://sparewotw.wordpress.com/2012/03/19/compiling-gimp-2-7-6-development-version-on-pclinuxos-kde4-2012-02/, thanks Andrzej. My desktop is Mate and his KDE but PCLinuxOS is based on Ubuntu like Mint, though packages are called slightly differently. If one is starting from plain new install he can start with:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential


Next libs for processing image and media formats like libtiff, libjpeg, libavcodec-extra-53, libvpx and so on. Naturally you will need corresponding dev packages also, since you want to compile against them. From development you will need Flex, Bison, Lua, Yasm; Python and Ruby you should already have. To get source code you need Git, source is at git://git.gnome.org/gimp and it is not marked as 2.9 but as 2.8, so do not get confused, check configure.ac and look for:

m4_define([gimp_app_version], [2.9])


I will not try to exactly list dependencies, you will see what is missing from error message if ./configure fails. Also going through Andrzej’s recommended list, one can do:

apt-cache search [package name without version number]

and see what is it called on Mint or Ubuntu or Debian.
Now following Andrzej’s tutorial download recommended dependencies, extract them where you want to build them, I do that in ~install. Do not deviate in package version since interfaces are changing and you will not be able to build. Now is time to start build, open terminal and elevate it to root level, cd where you will start build and set $PREFIX, $PATH and $PKG_CONFIG_PATH:

export PREFIX=`echo /usr/`
export PATH=$PREFIX/bin:$PATH
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig


While this is OK on clean box, rather go for /usr/local value for $PREFIX if you not doing it in VM or you do not have spare box for build. I also did

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib

First dependency is libffi-3.0.11 and as in Andrzej’s tutorial you just do, from the same terminal where those environment variables are exported:

./configure --prefix=$PREFIX
make
make install


This one should go without problems. You should see messages like this one:

Libraries have been installed in:
   /usr/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.


Next is glib-2.32.2 and quite few other packages are depending on it. When you finish building it do:

ldconfig
ldconfig -n /usr/lib


The first one clears library cache and the second one renews links in /usr/lib, that is where we are installing build output. To check situation do:

ldconfig -p | grep glib
ls -l /usr/lib | grep glib


The first prints links and the second one will say to what links are pointing, for example:

lrwxrwxrwx  1 root   root           23 Jan 20 22:24 libglib-2.0.so -> libglib-2.0.so.0.3200.2

If there are links to something like libglib-2.0.so.0.3400.3 they must be removed, together with libs. Check situation for libgio-2.0, libglib-2.0, libgmodule-2.0, libgobject-2.0 and libgthread-2.0. You should not have them unless you downloaded and did build of different version of glib. Leave alone lower versions like libglib-1.2.so.0.0.10, which may be there, but higher ones you should remove and links pointing to them. Tricky to configure and build is gtk+-2.24.10, if you run into problems double check are you bilding against right dependencies, if not get right ones and

make clean
ldconfig
./configure --prefix=$PREFIX


Like that all ten downloaded dependencies are built and installed and we can clone from GIMP repository source and finish build:

git clone git://git.gnome.org/babl
git clone git://git.gnome.org/gegl
git clone git://git.gnome.org/gimp
git clone git://git.gnome.org/gimp-gap


I didn’t even try gimp-gap since Andrzej was complaining that he can’t build it and GIMP works without it. For top three in the same order, cd in their root directory and:

./autogen.sh --prefix=$PREFIX
make
make install


GEGL was complaining about my custom FFmpeg and few other libs so I temporarily renamed offending libs and installed missing libx264-120 and libx264-dev. For example this is error message when make fails:

/usr/local/lib/libavformat.a: could not read symbols: Bad value

When GIMP is built you can run it executing:

/usr/bin/gimp-2.9


I run it from terminal because it prints debug messages to terminal. Plugins for GIMP 2.8 will naturally work, so install gimp-plugin-registry. If you see messages like this one

Gtk-WARNING **: Unable to locate theme engine in module_path: "murrine"

you will understand why is good idea to build it in VM. Enjoy.


No comments:

Post a Comment