Build GIMP 2.9 from git, GIMP 2.8, & GIMP 2.6,
each in its own prefix
This guide shows how to build and install multiple versions of GIMP — GIMP 2.9 from git, GIMP 2.8, and GIMP 2.6, with each version of GIMP in its own separate prefix. Specific information on this page was used to build GIMP on 64-bit openSUSE 12.2 in January, 2013 and again on 64-bit Gentoo in May, 2013 (when I switched from OpenSuse to Gentoo).
Written January 2013.
This article provides some nice background information on building GIMP from git and (in my opinion) is still worth reading if you've never built GIMP from git, and especially if you also want to build and run older versions of GIMP. However, updated and expanded instructions can be found in my three-part tutorial on building, updating, and patching GIMP from git.
If you don't know what you are doing, building software from source always involves risk of data loss. You could even completely incapacitate your computer. You shouldn't try to follow these steps blindly. Rather read the provided references and think carefully about what modifications in the procedure you might need to make before you begin. Use this guide at your own risk.
Install a development environment, git, and all the GIMP dependencies
Install git and a development environment from the openSUSE repositories
To access babl, GEGL, and GIMP from git, you need to install the package "git" from the openSUSE repositories.
To compile software from source code, first you need to install a "development environment" (also called a "build environment"). On openSUSE, the quickest way to install everything you need to compile ("build") software from source is to open Yast, click on the "Patterns" tab, scroll down to "Development", and check "Base Development". GIMP is written in C, so also check "C/C++ Development".
Install as many GIMP dependencies as possible from the openSUSE repositories
GIMP is very particular about the version numbers of certain critical dependencies. I have the following three programs installed from the openSUSE-12.2-Oss and openSUSE-12.2-Update-Oss repositories:
- gdk-pixbuf : 2.26.1 from the openSUSE-12.2-Oss repository.
- gtk+ : 2.24.10 from the openSUSE-12.2-Oss repository.
- glib2 : 2.32.4 from the openSUSE-12.2-Update-Oss repository.
GIMP has a lot of dependencies besides the three listed above. Probably the easiest way to to install all the necessary prerequisites is to just install GIMP using YaST. Or you can install just the GIMP dependencies using zypper at the command line:
sudo zypper in -d gimp root's password: Loading repository data... Reading installed packages... Resolving package dependencies... The following NEW packages are going to be installed: gimp gimp-branding-upstream libbabl-0_1-0 libgegl-0_2-0 libgimp-2_0-0 libgimpui-2_0-0 The following packages are recommended, but will not be installed: gimp-help-browser gimp-lang gimp-plugins-python The following package is suggested, but will not be installed: xsane 6 new packages to install. Overall download size: 7.8 MiB. Download only. Continue? [y/n/?] (y):
As my computer is set up for graphics editing, most of the GIMP dependencies are already installed. So the packages listed above are only the packages that zypper thinks I need to install before I can install GIMP. Your list of dependencies might be shorter or much, much longer.
As I'm going to install GIMP in a prefix (see below) that also has babl and GEGL installed in the same prefix, and as building GIMP also builds libgimp-2_0-0 and libgimpui-2_0-0, I actually don't need to install any of the dependencies that zypper listed. If zypper had listed things like "libpng", "libtiff", "glib", or "cairo", for example, that would be a different story.
Installing a dependency usually requires that you install the "-devel" package, which usually brings along all the other necessary files. Tracking down all the dependencies is the first hurdle to cross when compiling any package from source.
Why, how, and what "build GIMP in a prefix" means
Here are two excellent resources that explain how to build and install GIMP in a prefix:
- Compiling GIMP , written by "Lightning", is the guide that I followed most closely. Lightning's instructions explain step by step what is involved in building and installing a program in a prefix. If you don't understand Lightning's instructions, you shouldn't attempt to build GIMP. You've been warned.
- Shallowsky's GIMP Building Tips (for Linux) is very helpful in making it clearer what's involved in building GIMP from git, even though it was was written for Ubuntu Natty rather than openSUSE 12.2. Shallowsky's discussion of dependencies and prefixes is very good and should help reinforce what you learned from Lightning's instructions.
Everything below this point assumes that you've read the Lightning and Shallowsky articles. The only thing to watch out for is where Lightning uses "lib" I use "lib64". On my 64-bit openSUSE installation, GIMP can't find the appropriate balb and GEGL libraries in "lib" because they are installed in "lib64":
export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$LD_LIBRARY_PATH
What's the point of using a prefix?
If you don't understand the question, read the Lightning and Shallowsky articles.
Usually when you compile and install a program from source, you put it in "/usr/local/(bin, include, lib64, . . . )". Linux is set up so that programs installed in "/usr/local/(bin, include, lib64, . . . )" take precedence over programs installed in "/usr/(bin, include, lib64, . . . )". Usually this doesn't cause any problems. But if GIMP-2.8 is installed in "/usr/bin" and GIMP-2.9 is installed in "/usr/local/bin", any attempt to run GIMP-2.8 will run afoul of the fact that GIMP-2.8 and GIMP-2.9 require different versions of libgimp and libgimpui. OpenSUSE will pop up an unpleasant little message that says:
Libgimp version mismatch! The GIMP binary cannot run with a libgimp version other than its own. This is GIMP 2.8.0, but the libgimp version is 2.9.1. Maybe you have GIMP versions in both /usr and /usr/local ?
The solution is to install the different versions of GIMP each in its own prefix. The prefix acts like a little sandbox. When running a program installed in its own prefix, Linux will look for the various requisite libraries inside the prefix, before it looks in "/usr" or "usr/local". But programs not installed in the prefix won't ever try to find any libraries inside the prefix.
Where should you put your GIMP prefixes?
This is Linux, so prefix and source code folders can be located inside any folder that you own. The usual place is somewhere in your home folder, but that's not necessary. As it happens, I did put my prefixes in my home folder — one each for GIMP 2.6, 2.8, and 2.9 from git. I created two folders inside my home folder, one called "build" and one called "bin". My folder structure looks like the picture just above. The source code folders (where the code is compiled) are under "build" and the corresponding prefixes (where the installed files go) are under "bin". So your first step is to decide where you want to put your build and bin folders and create an appropriate set of folders.
Build order, compile times, configure options, and other preliminary considerations
Read the Lightning and Shallowsky articles first
The Lightning and Shallowsky articles listed above have really good explanations of the commands used to build and install from source when using a prefix, so hopefully you've already read those two articles. If you don't know what "SRC_DIR" and "INSTALL_PREFIX" mean, read those articles.
Extracting the contents of an achive
When building a program from source, usually the first step is to download the appropriate "tar.bz2" or other compressed archive and extract the contents. I usually use a gui program such as Ark. If you want to use the command line instead, the command is "tar xjvf filename.tar.bz2".
Build order and compile times
To install babl, GEGL, and GIMP, you need to install, in order, first babl, then GEGL, then GIMP. Why? Gegl needs babl. GIMP needs GEGL and babl.
Babl compiles quickly, GEGL almost as quickly. GIMP takes a bit more time.
Use './autogen.sh' or './configure' to specify build options
'./autogen.sh' and './configure' both allow you to specify which options you want to use when building a program from source code. Whether to use './autogen.sh' or './configure' depends on the source code. If the file "autogen.sh" is missing, there will be a file called "configure", and vice versa ("autogen.sh" actually generates a "configure" file).
Specifying the option "--prefix=$INSTALL_PREFIX" is necessary when building and installing a program in a prefix. Don't worry too much about './autogen.sh' and './configure' right now. It will be much clearer when you actually start building GIMP.
Whether to build documentation
The babl documentation takes a fairly long time to compile on my old, slow computer. To disable compilation of the babl documentation, inside the build folder, navigate to "babl(-version.number)/docs", open "Makefile.am" with a suitable text editor (geany, leafpad, bluefish, kate, gedit, etc), delete the entire contents, and then save "Makefile.am" as a 0-byte (empty) document. You can do the same thing with GEGL (navigate to "gegl(-version.number)/docs"). Whether or not to build the GIMP documentation is controlled explicitly using the option "--disable-gtk-doc".
Read the GIMP "INSTALL" file
Unlike babl and GEGL, there are quite a few options to choose from when building GIMP. Inside the GIMP source code folder (the folder that's created when you extract the contents of the "tar.bz2" file) there is a file called "INSTALL". Do read the "INSTALL" file (it opens with a text editor) for an explanation of the various install options.
As stated above, specifying the option "--prefix=$INSTALL_PREFIX" is necessary for building GIMP in a prefix. For GIMP, you probably also want "--disable-gtk-doc" because it takes some time to build and might not build successfully. When building GIMP from git, Lightning recommends using "--disable-python", I think probably because building the python portions of GIMP add to the compile time. I've left this last option out and still had GIMP build successfully.
All the remaining GIMP './configure' and './autogen' options are just that, optional, depending on your preferences. I usually disable building as much as possible: I don't print, don't need the documentation, don't need GIMP to access alsa or remote files, only have one processor, and don't have any need to open or save "wmf" (windows metafiles) or "aa" (ascii art) files, so I usually use all the corresponding "--disable" options.
Especially when building GIMP-2.6, disabling as much as possible lessens the chances of running into build issues where GIMP-2.6 requires an older version of one or another dependency, which dependency would need to be added to the GIMP-2.6 prefix, if it can even be built at all. The older the required version of a dependency, the less likely it can be successfully (or at least easily) built on a newer version of Linux.
If you run into a problem, the internet is your friend
Usually building and installing babl, GEGL, and GIMP in a prefix is a smooth, easy process. If you do encounter problems, your best bet is to search the internet: 99.999% of the time, someone out there in cyberland already had the same problem, and someone else already posted a solution.
Build and install GIMP 2.9 from git
Martin Nordholt's Best way to keep up with GIMP from git is directed at people who want to try their hand at GIMP development. If you want to build GIMP from git, it's worth reading Nordholt's article even if you never intend to change a single line of code. The following two bits of advice are extremely helpful:
- "to get updated with the latest changes from the constantly moving code base you regularly do 'git pull --rebase make make install'"
- "where things break, just run 'git clean -xdf' which removes all non-version-controlled files so that you can start over from autogen.sh". This bit of advice assumes that GIMP from git is broken because you made changes to the source code and broke GIMP from git yourself.
Remember — there are no guarantees that GIMP from git always works. Sometimes things that were working before might break because you just did "git pull --rebase make make install". At which point your options are: identity and fix the problem in the source code; wait until the GIMP developers identify and fix the problem; or use git to revert to a point where GIMP from git isn't broken (a topic beyond the scope of this guide). If GIMP from git is broken, the developers probably already know about it, but it never hurts to jump on the IRC #gimp channel and ask.
I built babl, GEGL, and GIMP-2.9 (all from git) in "/home/elle/build/gimp29" and installed them in "/home/elle/bin/gimp29". So my GIMP-2.9 SRC_DIR is "/home/elle/build/gimp29" and my GIMP-2.9 INSTALL_PREFIX is "/home/elle/bin/gimp29". (If you don't know what "SRC_DIR" and "INSTALL_PREFIX" mean, go back and read the Lightning and Shallowsky articles listed above.)
The first thing to do when building GIMP from git is to "git clone" babl, GEGL, and GIMP from git. Open a virtual terminal and type in the following commands, suitably modified to reflect where you want to build babl, GEGL, and GIMP from git:
cd /home/elle/build/gimp29 git clone git://git.gnome.org/babl git clone git://git.gnome.org/gegl git clone git://git.gnome.org/gimp
Before you run the "git clone git" commands, the build folder (in my case, "/home/elle/build/gimp29") is empty. Each of the "git clone git" commands creates an appropriately named subfolder before downloading the source code. For example, "git clone git://git.gnome.org/babl" creates a folder named "babl" and then downloads all the babl source code into the "babl" folder. So you don't need to worry about the babl, GEGL, and gimp source code getting all mixed up.
Now open a terminal and type the following commands, suitably modified to reflect what you called and where you put your INSTALL_PREFIX and SRC_DIR folders. Also, read the GIMP INSTALL file and modify the GIMP options to specify the options you want to use:
export INSTALL_PREFIX=/home/elle/bin/gimp29 export SRC_DIR=/home/elle/build/gimp29 export PATH=$INSTALL_PREFIX/bin:$PATH export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$LD_LIBRARY_PATH cd $SRC_DIR/babl ./autogen.sh --prefix=$INSTALL_PREFIX && make && make install cd $SRC_DIR/gegl ./autogen.sh --prefix=$INSTALL_PREFIX && make && make install cd $SRC_DIR/gimp ./autogen.sh --prefix=$INSTALL_PREFIX --disable-gtk-doc --disable-python make make install
Build and install GIMP 2.8
To build GIMP 2.8, I downloaded babl-0.1.10.tar.bz2 (just below babl-0.1.1.tar.bz2 in the list), gegl-0.2.0.tar.bz2, and gimp-2.8.2.tar.bz2 source code "tar.bz2" files. Each of these files is the latest stable version as of January, 2013.
I copied the "tar.bz2" files to "/home/elle/build/gimp28" and used Ark to extract the contents. So my GIMP-2.8 SRC_DIR is "/home/elle/build/gimp28". I installed all three programs in "/home/elle/bin/gimp28", so my GIMP-2.8 INSTALL_PREFIX" is /home/elle/bin/gimp28".
To build GIMP 2.8, first create an INSTALL_PREFIX and a SRC_DIR and download and extract the "tar.bz2" files to your SRC_DIR. Then open a virtual terminal and type the following commands, suitably modified to reflect what you called and where you put your INSTALL_PREFIX and SRC_DIR folders. Also, read the GIMP INSTALL file and modify the GIMP options to specify the options you want to use:
export INSTALL_PREFIX=/home/elle/bin/gimp28 export SRC_DIR=/home/elle/build/gimp28 export PATH=$INSTALL_PREFIX/bin:$PATH export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$LD_LIBRARY_PATH cd $SRC_DIR/babl-0.1.10 ./autogen.sh --prefix=$INSTALL_PREFIX && make && make install cd $SRC_DIR/gegl-0.2.0 ./autogen.sh --prefix=$INSTALL_PREFIX && make && make install cd $SRC_DIR/gimp-2.8.2 ./configure --prefix=$INSTALL_PREFIX --disable-gtk-doc make make install
Build and install GIMP 2.6
I chose to download the last stable version of GIMP-2.6, plus the versions of babl and GEGL that were current at the same time. So I downloaded the babl-0.1.6.tar.bz2, gegl-0.1.8.tar.bz2, and gimp-2.6.9.tar.bz2 source code "tar.bz2" files, copied them to "/home/elle/build/gimp26", and extracted the contents. I installed all three programs in "/home/elle/bin/gimp26". So my GIMP-2.6 SRC_DIR is "/home/elle/build/gimp26" and my GIMP-2.6 INSTALL_PREFIX is "/home/elle/bin/gimp26".
Building GIMP-2.6 was more difficult than building GIMP-2.8 or GIMP-2.9 from git. Babl-0.1.6 compiled and installed with no problem. However, GEGL-0.1.8 wouldn't build until I altered one line of code. Inside the build folder, navigate to "gegl-0.1.8/operations/external" and open "exr-load.cpp". Line 596 reads '*format = babl_format (format_string);'. It needs to read '*format = (void*)babl_format (format_string);':
The middle line below throws an error during make: *ff_ptr = format_flags; *format = babl_format (format_string); return TRUE; Change the code so it looks like this: *ff_ptr = format_flags; *format = (void*)babl_format (format_string); return TRUE; I copied the replacement line from the latest GEGL from git.
My first attempts at building GIMP-2.6 resulted in './configure' and 'make' terminating with various error messages. I installed libfm-devel from the openSUSE-12.2-Oss repository to eliminate a missing dependency error. A little internet research provide the answer to the linker problem: I had to put 'env LDFLAGS="-lgobject-2.0 -lglib-2.0 -lm"' in front of './configure'" to tell GIMP-2.6 where to look for various libraries.
I ended up compiling GIMP-2.6 several times to iron out the problems I encountered, but hopefully the steps listed below will go more smoothly for you.
To build GIMP 2.6, first create an INSTALL_PREFIX and a SRC_DIR and download and extract the "tar.bz2" files to your SRC_DIR. Alter the "gegl-0.1.8/operations/external/exr-load.cpp" file as indicated above. Then open a terminal and type the following commands, suitably altered to reflect what you called and where you put your INSTALL_PREFIX and SRC_DIR folders. Also, read the GIMP INSTALL file and modify the GIMP options to specify the options you want to use. With older versions of GIMP, the more you can disable, the better; but don't disable something you really want until you've tried and found out it didn't work.
export INSTALL_PREFIX=/home/elle/bin/gimp26 export SRC_DIR=/home/elle/build/gimp26 export PATH=$INSTALL_PREFIX/bin:$PATH export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$LD_LIBRARY_PATH cd $SRC_DIR/babl-0.1.6 ./autogen.sh --prefix=$INSTALL_PREFIX && make && make install cd $SRC_DIR/gegl-0.1.8 ./autogen.sh --prefix=$INSTALL_PREFIX && make && make install cd $SRC_DIR/gimp-2.6.9 env LDFLAGS="-lgobject-2.0 -lglib-2.0 -lm" ./configure --prefix=$INSTALL_PREFIX --disable-gtk-doc --disable-python --without-aa --without-wmf --without-webkit --without-poppler --without-print --without-gvfs --without-gnomevfs --without-libcurl --without-alsa --disable-mp --disable-gimp-console --disable-python make make install
How to start GIMP-2.6, GIMP-2.8, and GIMP-2.9 from their respective prefixes
Lightning gives an excellent discussion of how to actually start GIMP when it's been installed in a prefix, so reread the Lightning article to understand why and how what is described below works.
The basic problem to be solved is you can't start a program in a prefix until you tell your operating system that the program really is in a prefix; otherwise your operating system will try to start the wrong versions of the various programs and libraries that are in the prefix.
The solution is to create an executable file for each version of GIMP that you install in a prefix.
What goes into the executable files
GIMP-2.6: Open a text editor and type in (suitably modified to reflect your INSTALL_PREFIX and SRC_DIR):
#! /bin/bash export INSTALL_PREFIX=/home/elle/bin/gimp26 export SRC_DIR=/home/elle/build/gimp26 export PATH=$INSTALL_PREFIX/bin:$PATH export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH $INSTALL_PREFIX/bin/gimp-2.6 $@
I saved the file as "gimp26" and put it in "/home/elle/bin/gimp26". You should name it whatever you want and put it in the root of your INSTALL_PREFIX.
GIMP-2.8: Open a text editor and type in (suitably modified to reflect your INSTALL_PREFIX and SRC_DIR):
#! /bin/bash export INSTALL_PREFIX=/home/elle/bin/gimp28 export SRC_DIR=/home/elle/build/gimp28 export PATH=$INSTALL_PREFIX/bin:$PATH export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH $INSTALL_PREFIX/bin/gimp-2.8 $@
I saved the file as "gimp28" and put it in "/home/elle/bin/gimp28". You should name it whatever you want and put it in the root of your INSTALL_PREFIX.
GIMP-2.9 from git: Open a text editor and type in (suitably modified to reflect your INSTALL_PREFIX and SRC_DIR):
#! /bin/bash export INSTALL_PREFIX=/home/elle/bin/gimp29 export SRC_DIR=/home/elle/build/gimp29 export PATH=$INSTALL_PREFIX/bin:$PATH export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib64:$LD_LIBRARY_PATH export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH $INSTALL_PREFIX/bin/gimp-2.9 $@
I saved the file as "gimp29" and put it in "/home/elle/bin/gimp29". You should name it whatever you want and put it in the root of your INSTALL_PREFIX.
How to make the files executable
Lightning shows you a really neat way to create these files from the command line and also make them executable. But you can use your file manager to make them executable. In Dolphin, for example, right-click the file, select "Properties", select "Permissions", and check "is executable".
- Navigate to the appropriate folder and double-click on the executable file (eg: navigate to "/home/elle/bin" and click on the file "gimp26").
- Open a virtual terminal, navigate to the appropriate folder and type "./executable-filename" at the command line (eg: navigate to "/home/elle/bin" and type "./gimp26"). This allows you to see the terminal output (useful for debugging problems).
- Create links from the executable files to your Desktop and then click on the links (or icons, if you actually have a desktop; it's up to you to find icons; I use icewm, so my "Desktop" is really just a folder).
- Copy the executable files to any convenient location and click on them. As the executable files have complete path information, they don't need to be located in their respecitve prefix folders.
- If you run icewm, you can modify the icewm menu to include entries for each version of GIMP (eg for GIMP-2.6 I added "prog gimp-2.6-prefix none /home/elle/bin/gimp26/gimp26" to the icewm menu). I don't know how to add links to a gnome, kde, or other desktop menu, but it can probably be done.
Five different ways to start GIMP installed in a prefix
Screenshot of GIMP-2.6, GIMP-2.8, and GIMP-2.9 from git all running at the same time
Success! I opened all three versions of GIMP by clicking on the Desktop links; used "import" from the command line to make the screenshot. To get the screenshot ready for this article, I opened and worked on it using yet a fourth GIMP installation installed in "/usr/local", while the other three GIMP installations were still running in the background.