Building GIMP for artists and photographers
This is Part 1 of a three-part article on building and updating high bit depth GIMP from git. Part 1 (this page) shows you how to build high bit depth GIMP from git in a prefix. Part 2 shows you how to keep up with the latest changes in GIMP from git. And Part 3 shows you how to build a version of GIMP that has been patched to allow editing using RGB working spaces other than sRGB, using patched babl, GEGL, and GIMP code pulled from my github repositories.
Written June 2015. Updated January 2018.
Introduction: Why build GIMP from git?
Probably the most common reason to build GIMP from git is because you want to take advantage of code changes that haven't made it into the stable branch of GIMP, which currently is GIMP 2.8. Also, if you build GIMP from git, you have a chance to modify the code to make GIMP work better for your own editing needs, and in the process you might find that you've come up with a really good contribution to make to the GIMP code base.
My hope is that this three-part series of articles will make it a little easier for people with not much experience building software from source to build, update, and patch GIMP from git.
My other hope is that artists and photographers who can build, update, and patch GIMP might find they not only want to, but are able to, make contributions to GIMP development. GIMP is developed for artists and photographers, and so input and contributions from artists and photographers are crucially important. For would-be contributors to the GIMP code base, building GIMP from git is the first hurdle to overcome.
A word of caution — use this guide at your own risk. Building software from source always involves risk of data loss, mostly because it involves working at the command line, and the command line is very powerful. So read through the steps and think carefully about what modifications in the procedure you might want to make before you begin.
Getting the prerequisites and dependencies for building GIMP
Building GIMP from git requires that you set up a build environment and also install some dependencies. This sounds complicated, but it's not.
Set up a build environment
If you have never built software before, the first step is to set up what's called a "build environment" (also called a "development environment"). Most Linux distributions make this pretty simple to do. Hopefully the information below is correct for all of the listed Linux distributions:
- For Arch, at the command line type: sudo pacman -S base-devel
- For Debian and Debian derivatives like Ubuntu, Mint, and so on, at the command line type: sudo apt-get install build-essential
- For Fedora, type: sudo yum groupinstall 'Development Tools'
- For Gentoo (which I use), you already have a build environment.
- On OpenSUSE, 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".
Get the dependencies for building GIMP from git
GIMP has a lot of dependencies. You would think that the easiest way to make sure you have all the dependencies installed on your computer is to go ahead and install the version of GIMP supplied by your Linux package manager. This actually works for Gentoo, which is a rolling "built from source" distribution (when you build from git, you are building from source files).
However, for most Linux distributions, installing a package only install the binaries, that is, the already-compiled executables and libraries. But building babl/GEGL/GIMP from git means you also need the development files for many of the dependencies. For example, libpng is a GIMP dependency. But it's not enough to install just libpng. To build GIMP, you also need the development files for libpng.
Tracking down the name of every single package and development file you need to install before you can build GIMP from git would be time-consuming. Fortunately most Linux distributions make this process very simple:
- For Debian and Debian derivatives like Ubuntu, Mint, and so on, at the command line type: sudo apt-get build-dep gimp
- For Fedora, type: sudo yum-builddep gimp
- On OpenSUSE, type zypper si -d gimp
- An Arch expert over on the pixls.us forum very kindly provided the information that pacman -Si gimp will give you a list of required packages for building GIMP, and installing the dependencies does automatically bring in the development files.
- For Gentoo, you already have the development files for every package installed on your system.
As an aside, the commands for installing build dependencies through your package manager assume that you want to build the exact same software that's already in your package manager. This means that whatever is required by whatever version of GIMP would be installed by your package manager, those are the dependencies that will be installed. So dependencies you don't really want or need might get installed anyway. And dependencies that you do want or need might not get installed. Fortunately the build process itself will warn you of missing dependencies. So for a minimal build, you have the option to let the build process itself tell you about all the missing dependencies, and install as desired.
Finally, use your Linux package manager to install git. Git is the version control software that is used for babl, GEGL, and GIMP development (and for many other software packages — you can even use git to write a book; git will keep track of every change you make over time).
Building GIMP in a prefix
Set up some folders for building GIMP
I keep all code and programs that I compile from source in a folder named "code" inside my home folder. For this article, I'm putting all the required code for building GIMP from git in a subfolder named "gimpdefault" (this odd folder name is because I also build several modified versions of GIMP). These folder names are arbitrary, so please use whatever folder names you prefer. However, if you use the same folder structure that I use, then you can copy-paste the following commands. Otherwise you'll have to modify the commands to reflect your own folder structure:
# Open a terminal and make some folders # that will allow you to build and install GIMP: # # Linux knows that "$HOME" (without the quote marks!) # means your home folder. # So on my computer typing "$HOME" in the terminal # is exactly the same as typing "/home/elle". # # I put the gimpdefault prefix folder in my home folder # in the subfolder "code" where I build software from source. # # If you intend to use the same folder structure, # you can copy-paste the following commands: mkdir $HOME/code mkdir $HOME/code/gimpdefault mkdir $HOME/code/gimpdefault/build mkdir $HOME/code/gimpdefault/install mkdir $HOME/code/gimpdefault/install/share mkdir $HOME/code/gimpdefault/install/share/aclocal touch $HOME/code/gimpdefault/install/share/aclocal/gimp-2.0.m4
Clone the software for building GIMP
GIMP depends on babl and GEGL, and the three programs update in lock-step with one another. So even after you install all the GIMP dependencies through your Linux package manager, you'll still need to install the latest versions of babl and GEGL from git in your gimpdefault folder.
I run Gentoo, which supplies relatively recent versions of all of GIMP's dependencies. But depending on what version of Linux you run, you also might need to install in the gimpdefault prefix folder a newer version of glib, and/or various other GIMP dependencies, than is provided by your Linux package manager. Fortunately if you are missing any dependencies, the process of building babl, GEGL, and GIMP will let you know by printing appropriate error messages to your terminal screen.
Obtaining software from git is called "cloning", which sounds scary, but is actually very simple to do. So now that you have folders set up for building GIMP in a prefix, the next step is to clone babl, GEGL, and GIMP from git. You'll also need to clone any other required dependencies that might not be recent enough as supplied by your Linux package manager:
Note: All the clone steps below use the command "git clone git://location-of-git-repository". If this command produces an error message, try "git clone https://location-of-git-repository"
# The first step is to "cd" to the gimpdefault build folder: cd $HOME/code/gimpdefault/build # The list of dependencies that you'll # need to installdepends on how recent your # Linux package-manager-installed packages are, # compared to the versions required by GIMP from git. # # Unfortunately the only way to know for sure what # dependencies you might need to clone and build # is to try to build babl, GEGL, and GIMP # and see what the build process complains about. # # I run an up-to-date Gentoo Linux, # But I still need certain packages # that are newer than what's available from Gentoo. # Installing these packages from git makes it easy to # keep up with future bumped requirements for GIMP. # # You might need to build glib in your prefix. If so, # go ahead and clone glib from git: git clone git://git.gnome.org/glib # You might also need gdk-pixbuf from git. # Gentoo portage currently supplies gdk-pixbuf-2.30.8, # which is recent enough to build GIMP from git. # # It doesn't hurt to install gdk-pixbuf from git # even if you don't really need to. # # In case your Linux package manager # doesn't supply a new enough version of gdk-pixbuf, # here's the command to clone gdk-pixbuf from git: git clone git://git.gnome.org/gdk-pixbuf # And of course you need to clone babl, GEGL, and GIMP: git clone git://git.gnome.org/babl git clone git://git.gnome.org/gegl git clone git://git.gnome.org/gimp # Update 1: Not too long ago I followed these instructions to build # GIMP from git on minimal installs of Debian Sid and OpenSuse 13.2. # Neither of these distributions is quite as up to date as Gentoo. # Here are the "git clone" commands I used for Debian and OpenSuse. # Notice the additional "git clone" for "json-glib": git clone git://git.gnome.org/glib git clone git://git.gnome.org/json-glib git clone git://git.gnome.org/gdk-pixbuf git clone git://git.gnome.org/babl git clone git://git.gnome.org/gegl git clone git://git.gnome.org/gimp # Update 2: As of December 2015, GIMP depends on libmypaint, which you'll almost certainly have to compile from git: git clone git://github.com/mypaint/libmypaint.git # Update 3: As of January 2018, GIMP depends on the mypaint brushes. At least for now you'll have to clone the software: git clone https://github.com/Jehan/mypaint-brushes.git
Set up the prefix for building babl/GEGL/GIMP from git
Now you have babl, GEGL, libmypaint, the mypaint brushes, and GIMP cloned from git. And you've also cloned glib, and also maybe json-glib and gdk-pixbuf, which hopefully are the only babl/GEGL/GIMP dependencies that you'll need to install in the prefix before you can install babl/GEGL/GIMP from git.
The next step is to tell your Linux operating system that you want to build software inside a prefix. This process is called "setting up a prefix" or "establishing a prefix":
# Establish your prefix by copy-pasting the following commands: # # You don't really need to understand the details # of the commands for setting up a prefix. # All you really need to do is copy-paste the commands. # # But what the following commands actually do is tell your Linux OS to # "First look inside the prefix for various libraries, # and use the prefix-installed libraries instead of any equivalent libraries # that might be installed in /usr or /user/local": PREFIX=$HOME/code/gimpdefault/install export PATH=$PREFIX/bin:$PATH export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal" export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH export GIO_EXTRA_MODULES=/usr/lib/gio/modules export SRC_DIR=$HOME/code/gimpdefault/build #In the lines that contain "lib", you might need to use "lib64" instead. # "lib" is correct for 64-bit Gentoo. But some Linux distributions use "lib64". # For example, OpenSuse does use lib64. # So if your distribution uses lib64 instead of lib, # then in the above export commands, replace "lib" with "lib64". # # Correspondingly, in the line that reads "export GIO_EXTRA_MODULES=/usr/lib/gio/modules" # the lib subfolder can very from one distribution to the next. # "/usr/lib/gio/modules" is correct for 64-bit Gentoo. # Use "/usr/lib/x86_64-linux-gnu/gio/modules" for 64-bit Debian. # Use "/usr/lib64/gio/modules" for OpenSuse. # If anyone knows of a command for determining the # correct folders for "lib" versus "lib64" and the corresponding "gio" subfolder, # please let me know.
Building GIMP in a prefix means you can build and run several different versions of GIMP, each in its own prefix, with no interference between the different versions.
Figure out how many cores your computer has
Before you start building any software in the gimpdefault prefix, it's a good idea figure out how many cores your computer has available for building software. The more cores you can use, the faster the software will build. Here's the command for ascertaining how many cores your computer has:
cat /proc/cpuinfo | grep processor | wc -l
When you build software, you can tell your computer how many cores to use by means of the "-j" switch. This sounds a lot more complicated than it is. The next section below on building and installing GIMP in the prefix tells you exactly where and how to use the "-j" switch. Right now all you need to do is figure out how many cores you have.
For reasons I don't understand, the usual recommendation is to add "1" to the number reported by the above command. In other words, you pretend like your computer has one more core than it really does. For example, my ten-year-old computer (which finally stopped working) had two physically separate cpus, but each cpu only has one core. So when I ran the above command, "2" was printed to the screen. So I would add "2+1" to get 3. And so 3 was the number that I used with the "-j" switch, as "-j3". My new computer reports 8 cores, but I choose to build using only 5 of the 8 cores (so I can continue with other tasks while building software), so now I use "-j5".
Build and install glib/babl/GEGL/GIMP in the prefix
Now that glib, libmypaint, the mypaint brushes, and babl/GEGL/GIMP have been cloned in the gimpdefault prefix "build" folder, it's time to actually build glib, libmypaint, the mypaint brushes, babl, GEGL, and GIMP. In the steps given below, running "autogen.sh" will tell you if you need additional dependencies either to compile the software at all or else to supply additional functionality that you might (or might not) actually want.
If it turns out that babl, GEGL, or GIMP does need an additional or newer dependency that what you already have installed, then during the build process (that is, while running "make"), an error will be printed to screen and the build process will stop. This gives you a chance to find and install the missing dependency.
If you don't want to discover missing dependencies one by one during the build option, at least for GIMP you can open the file "configure.ac" (it's in the root GIMP build folder) — all the required software and also the required version of each software is listed in this file. Be careful not to accidentally modify the file while you are searching through it.
If you do need additional dependencies, hopefully they can be installed from your package manager. If you need a newer version of a dependency, that can't be updated through your package manager, then you'll have to download (or clone) the newer version of the required software and install it in the prefix.
Tracking down missing dependencies is never fun. But once you finish installing babl, GEGL, and GIMP from git the first time, it will probably be a long, long time before you ever need to track down another dependency.
# You already set up the gimpdefault prefix. # But it certainly doesn't hurt to repeat the commands, # and repeating the commands is required if you've just # restarted your terminal, or opened a new window, or moved # to a new tab in a multi-tabbed terminal like konsole. # # Don't forget to modify the "lib" and "gio" lines to match what # is required by your Linux distribution! PREFIX=$HOME/code/gimpdefault/install export PATH=$PREFIX/bin:$PATH export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal" export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH export GIO_EXTRA_MODULES=/usr/lib/gio/modules export SRC_DIR=$HOME/code/gimpdefault/build # Now cd to the prefix build folder, # where you've already cloned babl/GEGL/GIMP # and also glib: cd $SRC_DIR # In the commands below, change the "3" in "-j3" # as appropriate for your computer. # However, nothing bad happens if you just use "-j3". # The order of installation matters. # If your Linux package manager doesn't supply a new enough version of glib, # first install glib: cd $SRC_DIR/glib ./autogen.sh --prefix=$PREFIX # if you check the terminal output, # you'll see options to disable building documentation. # Doing so will reduce the compile time. # The same holds true for json-glib, gdk-pixbuf, babl, GEGL, and GIMP. make -j3 make -j3 install # Next install json-glib, if necessary. # I don't know how to tell if json-glib is necessary, # other than by attempting to install babl/GEGL/GIMP # and seeing if any error messages are printed to the screen. # It's perfectly OK to build json-glib even if you don't really need to: cd $SRC_DIR/json-glib ./autogen.sh --prefix=$PREFIX make -j3 make -j3 install # Next install gdk-pixbuf, if necessary. # I don't know how to tell if gdk-pixbuf is necessary, # other than by attempting to install babl/GEGL/GIMP # and seeing if any error messages are printed to the screen. # It's perfectly OK to build gdk-pixbuf even if you don't really need to: cd $SRC_DIR/gdk-pixbuf ./autogen.sh --prefix=$PREFIX make -j3 make -j3 install # Once installed in the gimpdefault prefix, # there's no need to update glib, json-glib, gdk-pixbuf, # or other dependencies that you installed in the gimpdefault prefix # until babl, GEGL, or GIMP bumps the required versions. # Next install babl: cd $SRC_DIR/babl ./autogen.sh --prefix=$PREFIX --disable-docs make -j3 make -j3 install # Notice the options "--disable docs". # You don't really need to use this option. I'm just giving you # the options I use. # # Building the babl docs takes a very long time, # which is why I disable building the docs. # # Once you run the "./autogen" command for the first time, # You can see a list of babl "build options" # by typing "./configure --help" (without the quotes, of course). # # GEGL and GIMP also have their own sets of build options, # that also can be displayed using the same "./configure --help" command. # Next install GEGL: # babl installs pretty quickly if you disable building the docs. # GEGL takes a little longer, and GIMP takes a lot longer. cd $SRC_DIR/gegl ./autogen.sh --prefix=$PREFIX --enable-gtk-doc-html=no --enable-workshop # After running "./autogen.sh" for GEGL, # and assuming autogen.sh finished running with no problems, # take a minute to read through the terminal printout to see whether # there are any additional dependencies that you might want to install # (hopefully through your Linux package manager) # before proceeding to install GEGL. # If so, install the dependencies and then rerun "./autogen.sh". make -j3 make -j3 install # Next install libmypaint. You need to "check out" a particular branch before you start compiling. I'll just give you the command and leave it up to you to figure out what "checking out a branch" means": cd $SRC_DIR/libmypaint git checkout v1.3.0 ./autogen.sh --prefix=$PREFIX ./configure --prefix=$PREFIX # Unless something has changed recently, # for libmypaint you do need to run ./autogen.sh and then ./configure make -j3 && make -j3 install # Next install the mypaint brushes. Just as with libmypaint, you need to "check out" a particular branch before you start compiling the brushes: cd $SRC_DIR/mypaint-brushes git checkout v1.3.0 ./autogen.sh --prefix=$PREFIX ./configure --prefix=$PREFIX # You do need to run ./autogen.sh and then ./configure make -j3 && make -j3 install # Next install GIMP: cd $SRC_DIR/gimp ./autogen.sh --prefix=$PREFIX --disable-gtk-doc --with-gimpdir=$HOME/code/gimpdefault/install/config # After running "./autogen.sh" the first time for GIMP, you can # check the configure options for GIMP ("./configure --help") and then use "./configure" to modify the default compile options. make -j3 make -j3 install
Running "autogen.sh" normally tells you if you are missing any dependencies. However, sometimes "autogen.sh" fails to detect a missing dependency, in which case the glib/babl/GEGL/GIMP build processes will eventually stop because of the missing dependency. At this point the next step is to identify and install the required software. There will be more or less helpful error messages printed to the screen.
When tracking down what caused the error message, the internet is your friend. And you can also ask on the pixls.us forum, #gimp or #gimp-users IRC (the people who hang out on the gimp IRC channels are both friendly and helpful) or on the GIMP users or developers mailing lists. You don't have to join the GIMP mailing lists to send an email. But you probably won't see all the answers unless you either subscribe or visit one of the archives, because many people send answers to the list and not also to the individual who made the initial post.
Once you track down and install the missing dependency, then (re)install all the software in the prefix, in the same order as given above. This is to make sure that all the software in the prefix is installed using the same software libraries.
The good news is once you've made it all the way through the initial installation, it's usually smooth sailing after that. The worse that's likely to happen is a dependency version will be bumped, and the resulting error messages will tell you exactly what newer version you need.
For convenience, the commands without all the comments
If you already know how to build GIMP in a prefix, and your Linux distribution is up-to-date enough that glib, libmypaint, and the mypaint brushes are the only additional dependencies that you'll need besides babl, GEGL, and GIMP, then you can open a terminal and copy-paste the following commands. You might want to change the "-j3" switch to match the number of cores on your computer. And you might want to change the folder structure and build options for babl, GEGL, and GIMP to suit your own needs.
The comments (lines in red that are preceeded by "#") are just ignored by your Linux OS, so they can be copy-pasted right along with the actual commands. I would advise waiting for each build to finish before starting the next (instead of copy-pasting all the cd/autogen.sh/make/make install commands in one fell swoop). This will make it easier for you to tell when and where any problems arise.
# Set up some folders mkdir $HOME/code mkdir $HOME/code/gimpdefault mkdir $HOME/code/gimpdefault/build mkdir $HOME/code/gimpdefault/install mkdir $HOME/code/gimpdefault/install/share mkdir $HOME/code/gimpdefault/install/share/aclocal touch $HOME/code/gimpdefault/install/share/aclocal/gimp-2.0.m4 # Clone the software — add to this list as needed on your system. cd $HOME/code/gimpdefault/build git clone git://git.gnome.org/glib git clone git://git.gnome.org/babl git clone git://git.gnome.org/gegl git clone git://github.com/mypaint/libmypaint.git git clone git://git.gnome.org/gimp git clone https://github.com/Jehan/mypaint-brushes.git # Set up the prefix, modifying the GIO_EXTRA_MODULES and the "lib" path as #required for your version of Linux: PREFIX=$HOME/code/gimpdefault/install export PATH=$PREFIX/bin:$PATH export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal" export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH export PKG_CONFIG_PATH=$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH export GIO_EXTRA_MODULES=/usr/lib/gio/modules export SRC_DIR=$HOME/code/gimpdefault/build # Build and install glib/babl/GEGL/libmypaint/the mypaint brushes/GIMP in the # prefix — add to this list as needed on your system. cd $SRC_DIR/glib ./autogen.sh --prefix=$PREFIX make -j3 && make -j3 install cd $SRC_DIR/babl ./autogen.sh --prefix=$PREFIX --disable-docs make -j3 && make -j3 install cd $SRC_DIR/gegl ./autogen.sh --prefix=$PREFIX --enable-gtk-doc-html=no --enable-workshop make -j3 && make -j3 install cd $SRC_DIR/libmypaint git checkout v1.3.0 ./autogen.sh --prefix=$PREFIX ./configure --prefix=$PREFIX make -j3 && make -j3 install cd $SRC_DIR/mypaint-brushes git checkout v1.3.0 ./autogen.sh --prefix=$PREFIX ./configure --prefix=$PREFIX make -j3 && make -j3 install cd $SRC_DIR/gimp ./autogen.sh --prefix=$PREFIX --with-gimpdir=$HOME/code/gimpdefault/install/config --disable-gtk-doc make -j3 && make -j3 install
Running GIMP from the gimpdefault prefix
Now you have GIMP installed in your gimpdefault prefix. You might also have GIMP installed from your Linux package manager. And you might have other versions of GIMP installed in other prefixes. So the next step is to make it possible to actually run the version of GIMP that you installed in the gimpdefault prefix.
With a plain text editor (leafpad, geany, bluefish, etc), make a document with the following lines:
#! /bin/bash PREFIX=$HOME/code/gimpdefault/install export PATH=$PREFIX/bin:$PATH export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal" export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH export GIO_EXTRA_MODULES=/usr/lib/gio/modules export SRC_DIR=$HOME/code/gimpdefault/build $PREFIX/bin/gimp-2.9 -n$@
Save the plain text document as "rungimpdefault" in some convenient location. I save it in the gimpdefault prefix folder "$HOME/code/gimpdefault"). Then make the "rungimpdefault" file executable by cd'ing to the folder where you saved rungimpdefault, and then typing:
cd $HOME/code/gimpdefault chmod +x rungimpdefault
To start "gimpdefault", navigate ("cd") to folder with the ".sh" file ("cd $HOME/code/gimpdefault") and type "./rungimpdefault":
cd $HOME/code/gimpdefault ./rungimpdefault
Conclusion, and congratulations if you made it this far!
Well, I hope building GIMP from git in the gimpdefault prefix wasn't too difficult. But succeeding really is an accomplishment. So if you made it this far, congratulations! You deserve a great big round of applause, especially if you've never built software from source before.
Now that you've built GIMP in a prefix, Updating GIMP from git for artists and photographers shows you how to keep up with the latest versions of babl, GEGL, and GIMP from git.