Compiling GIMP

In this page, I'll try to keep some updated instructions on compiling GIMP, both on Windows and on Linux. This page is not going to have "copy paste" instructions, since I want you to understand what you are doing. If you are looking for a "paste this on the command line" guide, you should go look elsewhere – you won’t find it here.

Perquisites: You should know roughly what is a command-line/terminal/shell. and what are environment variables. You should also know how to open the command-line/terminal/shell.

Finally, any Suggestions/Corrections/Feedback will be highly appreciated! If you didn’t succeed to build GIMP using the technique described here, tell me what’s the error (leave a comment) and I’ll see if I can help!

Updates

  • Update 1 (Jan 15, 2011): Added a part about updating your build
  • Update 2 (Jan 30, 2011): Added instructions on compiling on windows (without cygwin!), for pre-packaged sources
  • Update 3 (Jan 30, 2011): Fixed a small bugs which caused stuff to be extracted to the wrong place (mainly libtiff/libjpeg/libwmf. Perl was also extracted to the wrong place, but it didn’t affect the compilation).

Instructions for compiling on windows from git, will be posted later.


Warning: Installing software and making changes to your system, is risky, especially if you don't know what you are doing! This guide is written in hope that it will be helpful, but it's without any guarantee that it will work or that it won't damage your computer. I’m not responsible for any damage caused to your computer by following any part of this guide. In short, Follow at your own risk!


Compiling GIMP 2.7 on Linux

This guide will explain you how to install GIMP, even without root/admin permissions/privileges. It will explain how to install GIMP to a custom location so that it won’t conflict with your existing GIMP installation. Through this guide, I’m going to use the bash shell for executing stuff from the command line – it’s usually located in /bin/bash.

The Basics - Environment Variables

The main "problem" (don't worry, it's solvable) with compiling gimp on Linux, is environment variables. There are 3 environment variables which we should get to know when compiling things on Linux, and we’ll now present them:

PATH

First of all, this environment variable specifies where to look for executables. When you type "gimp" in the command line, all the directories inside the path will be searched.

lightning@nova:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local32/bin:.

As you can see, the path is composed out of a list of paths to directories, separated by ':' signs. The order of directories inside the path does matter! Directories which are listed first, are searched first!

PKG_CONFIG_PATH

This environment variable tells the pkg-config tool (a tool which is used to resolve most dependencies in GIMP’s compilation) where to look for the config files (which are used by pkg-config) for installed libraries.

LD_LIBRARY_PATH

Many executables used files which are called shared libraries – these files contain functionality that should be shared between executables. One example which you should know (if you are a Linux user) is Gtk+ – the library which is used by many applications (including GIMP) to create the user interface.

The executables search for these libraries inside some directories which are considered as “default”. So, in order for us to install and use libraries in other locations we need to update this variable to point to the directory leading to these libraries.

What’s the problem with environment variables?

We don’t want to compile GIMP and install it in the default location, because then it may conflict with our existing installation. But if we install GIMP at a different location, we need to configure the environment variables so that the correct versions of libraries will be found and used, both for compilation and for running GIMP.

Preparing for compilation

First of all, we need to decide where do we want to install the alternative version of GIMP. To make it easy to remember and use, we’ll define an environment variable containing that path:

export INSTALL_PREFIX=/vol/scratch/gimp-beta/build

We will also need a directory to download the sources to; this is the directory I used:

export SRC_DIR=/vol/scratch/gimp-beta/src

You’ll need to make sure both of these directories actually exist. You can do it by running following command:

mkdir -p $INSTALL_PREFIX
mkdir -p $SRC_DIR

Now, remember the discussion we had about environment variables? Here are the updates we need to do:

export PATH=$INSTALL_PREFIX/bin:$PATH
export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib:$LD_LIBRARY_PATH

In the first line, we update the PATH variable, so that looking for executables will begin in our installation directory (executables will be installed into the bin subdirectory). In the second line, we tell pkg-config that it should begin searching for library config files in our installation directory. This will resolve many compilation issues! For example, this will allow us to compile plug-ins against our updated version of the GIMP libraries, even if we have the old ones installed. In the third line, we tell the library loader that it should first of all try to look for libraries in our installation directory – this will prevent it from loading the libraries of other GIMP versions (that can cause trouble…).

GIMP’s dependencies

Before you rush to get any of the dependencies listed below, stop. You may have some of them, or even all of them without you even new about it. Any recent Linux distribution should have the general dependencies listed below, and we’ll target the GIMP specific dependencies below.

General dependencies
  • GLib – a library used by many gnome applications, containing utilities and common data structures for programs written in C.
  • GTK+ – a graphical toolkit for building cross-platform user interfaces.
  • Cairo – a 2D graphics library, used for drawing some of GIMP’s widget and also used by Gtk+.
  • librsvg – a library for rendering SVG (Scalable Vector Graphics) files.
  • libpng – a library for reading and writing PNG (Portable Network Graphics) image files. Used by Gtk+, GIMP and GEGL.

GIMP-specific dependencies
  • babl – a library for converting between pixel formats, heavily used by GIMP when communicating with GEGL.
  • GEGL – a graph based image processing library, heavily used in GIMP’s core

In order to build GIMP from the latest source (and not from a ready source packages), you’ll need to have Perl installed, along with some other utilities such as intltool. If you want to compile GEGL from the latest source (as proposed below), you’ll need to have Ruby installed. You shouldn’t worry about these if you have a decent linux distribution which was updated anywhere in the last year or two.

If you want GIMP to have Python support (optional), you’ll need to install Python (version 2, not 3!) along with PyGTK+. If you want to be able to build GIMP’s documentation (optional), you’ll need to have gtk-doc installed.

Compiling babl, GEGL and GIMP from source

The procedure for compiling babl, GEGL and GIMP is very easy once you have the dependencies. Note that the order here matters – we first need to have babl, then GEGL and finally GIMP.

Compiling the latest source (from Git)

First of all, you’ll need Git (the version control tool which is used for managing the sources of babl, GEGL, GIMP and many other projects). To download the sources, invoke the following commands:

cd $SRC_DIR
git clone git://git.gnome.org/babl
git clone git://git.gnome.org/gegl
git clone git://git.gnome.org/gimp

Now, the procedure for compiling is very simple:

  • Run the autogen script – this script generates the makefiles based on your system’s configurations, and tries to make sure you have all the dependencies.
  • Run the ‘make’ command to compile the sources (do this only if the autogen script finished successfully!)
  • Run the ‘make install’ command to install the compiled sources (do this only if the compilation was successful!)

# Install BABL
cd $SRC_DIR/babl
./autogen.sh --prefix=$INSTALL_PREFIX && make -j4 && make install

# Install GEGL
cd $SRC_DIR/gegl
./autogen.sh --prefix=$INSTALL_PREFIX && make -j4 && make install

# Install GIMP
cd $SRC_DIR/gimp
./autogen.sh --prefix=$INSTALL_PREFIX --disable-gtk-doc --disable-python --enable-debug
make -j4
make install -j4

Explanation:

  • The autogen.sh script generates a script called configure, which recieves the arguments that were passed to the autogen.sh script
  • The --prefix argument to the configure script tells the configuration script that the installation should be done to a location different than the default location
  • The -j4 argument to the make program, tells it that the task should be done using 4 jobs. Use this if you have 4 cores on the computer to speed up things by using several cores! If you have less cores, specify the appropriate number. You can simply remove that argument if you don’t know how many cores you have, or if you want to run a single job
  • When compiling GIMP we also passed the --disable-gtk-doc argument, to specify that we don’t want to build the documentation. Do this if you don’t have gtk-doc or if you don’t want to build the documentation (could be long to build, and it’s not going to be of any use unless you plan to develop GIMP itself or plug-ins for it).
  • When compiling GIMP we also passed the --disable-python argument, to specify that we don’t want to build the python plug-in support. Do this if you don’t have python/PyGTK+ or if you don’t want the python support.
  • When compiling GIMP we also passed the --enable-debug argument, to specify that GIMP should be built with debug information.

Note that we disabled python and gtk-doc above by default. You can try removing these arguments, and see if the autogen script finishes successfully. If you plan on running the autogen script several times, try adding the -C argument to enable caching of some of the results – this will speed things up.

Running our compiled version of GIMP

Now, we should be careful before running GIMP. Our compilation was done with some very specific environment variables, and running GIMP will depend on them! So, let’s save our environment variables into a script that runs GIMP:

echo "#! /bin/bash

# set the path to the installation directory
export INSTALL_PREFIX=$INSTALL_PREFIX

# set the path to the directory into which we download the sources
export SRC_DIR=$SRC_DIR

# Now, set mandatory enviroment variables
export PATH=\$INSTALL_PREFIX/bin:\$PATH
export LD_LIBRARY_PATH=\$INSTALL_PREFIX/lib:\$LD_LIBRARY_PATH

# Not needed for running GIMP directly, but needed if you want to compile anything against our
# builds (think of plug-ins, etc.)
export PKG_CONFIG_PATH=\$INSTALL_PREFIX/lib/pkgconfig:\$PKG_CONFIG_PATH

# Now you can run executables our other stuff depending on our environment
# Here we run GIMP, and pass it any arguments given to this script
\$INSTALL_PREFIX/bin/gimp-2.7 \$@

# If you want to run something else, copy paste into bash everything before the line that
# runs GIMP, and then run it
" > $INSTALL_PREFIX/run-gimp.sh

chmod +x $INSTALL_PREFIX/run-gimp.sh

This command creates a script file called run-gimp.sh (inside our installation directory), which sets our environment variables, and then runs GIMP. The script will also contain instructions about running things other than GIMP using our environment. If you finished this step without erros, you should now have a working build of GIMP!

Compiling source from a ready package (Alternative to downloading from Git)

You can download a source package for GIMP/babl/GEGL on their respective sites. In order to compile these, you’ll need to replace the call to ./autogen.sh with a call to ./configure, and that’s about it (you still pass the same arguments!).

Troubleshooting
  • “I’m getting an error about a too low of GTK+/GLib while compiling XXX”
    You can either update your version of GTK+/GLib using your system’s package manager, or compile GTK+/GLib from source! Compiling these is done exactly like we compiled babl – download the source (either the latest from Git, or a package from the official site), compile and install. You may also need to do something like this to a library called ATK.
  • “I’m getting some error about relative path in the prefix”
    The installation directory of libraries/executables must be specified in an absolute path and not in a relative path. If you got this error, it means that one of the paths in your environment variables is relative and not absolute – fix that!
  • “Package babl was not found in the pkg-config search path…”
    Reader phani reports that he had some problems that made pkg-config fail to find babl on his machine. He said that he solved it by copying babl.pc from $INSTALL_PREFIX/lib/pkgconfig to $INSTALL_PREFIX/build/lib/pkgconfig. This problem shouldn’t happen to you in any normal case! However, if it does, please leave a comment here saying that you also encountered it!
    As he asked for, I removed his comment and I’m just leaving this note here.


Updating Your GIMP Build (Git only)

If you checked the source of GIMP from Git, you probably want to be able to update your build. To do this, we need first of all to fetch the updated sources.

cd $SRC_DIR/gimp
git pull

Now, if you get warnings about conflicts that prevent you from updating, see what are these warnings. If you added some files or made changes that you want to keep, do this (I recommend finding a Git tutorial for this, such as the excellent Git Magic). If any changes were unintentional, run the following (warning! Recovering the changes will not be possible!):

git reset --hard

Now try again the pull command.

Now that we have the updated sources, you can try to rebuild gimp (the call to autogen, then make and make install). Some people would tell you that we should have called make clean or make distclean before this step (These clean any remains of the last compilation). Well, the general case is that not too much of the source changes between updates, so why re-build everything? The make utility usually succeeds in building only the things that were changed, so give it a try.

If you see that your build fails, then you should try running the following command (Warning! Will remove all the files which are not directly tracked by git!):

git clean –dfq

Now, try repeating the reset command and building. It should work now.

The procedure described above can be applied also to update GEGL and babl.


Compiling GIMP 2.7 on Windows (from packages, not from Git)

Compiling GIMP on Windows is very similar to compiling on Linux, but with one catch: It’s much more complex, and you can get screwed up in so many ways… If you wish to read and follow the instructions here, you must make yourself familiar with the process on Linux as described above (you don’t have to try it if you don’t have a Linux computer available, but you should read it fully and try to understand it).

Compiling GIMP natively on windows can be hard, and it may break-up because of every little change in any of the dependencies. I am going to try and keep this updated, but you should try to understand what’s going on, and you should not be afraid of error messages! Google is your friend and you should expect the unexpected.

In this part I’m going to post the instructions for compiling GIMP and friends from pre-packaged sources, and not from Git. This is since compiling from Git requires some more steps which are not that trivial (these will be covered in the next version of this document).

For the sake of having a hopefully deterministic result, I’m going to post the exact versions of some of the packages/tools/sources I used.

Directory Structure

We will use the following directory structure for compiling GIMP:

  • gimp-win-beta – The root directory of everything we are doing. Can be located anywhere on the disk, as long as the path to it does not contain spaces!
    • build – In this directory we will install and compile programs
    • downloads – In this directory we will save all the files we are going to download (And their will be plenty of these!) in an organized way so we can find our way around.
    • perl – Will be explained later
    • git – Will be explained later

So, create this directory tree somewhere on your disk, in a path which has no spaces in it! I suggest:

  • C:\gimp-win-beta
    • C:\gimp-win-beta\build
    • C:\gimp-win-beta\downloads
    • C:\gimp-win-beta\perl
    • C:\gimp-win-beta\git

For the rest of this guide, I’m going to refer to these directories as GIMP_BETA_DIR, BUILD_DIR, PERL_DIR, GIT_DIR. Now, let’s get started.

MinGW and MSYS

Let’s face it – Linux comes with so many tools that windows doesn’t. It comes with a compiler suite known as GCC (Gnu Compiler Collection), with scripting languages (such as Perl, Python and Ruby) and many many configuration tools which are supposed to “simplify” the process of compilation (yeah right…). Windows does not come with the tools I mentioned above, so we need to get ourself a basic environment containing some of these tools.

MinGW – Minimal Gnu for Windows, is a collection of native Windows ports of the Gnu Compiler Collection (unlike Cygwin, which tries to emulates a Unix environment on windows). MSYS – Minimal System, is a collection of Windows Ports of utilities such as make, grep (Generalized Regular Expression Parser), bash (A Unix Shell).

Installing the MinGW compilers along with MSYS, is essential if we want to compile Unix/Linux programs on windows, in cases where the build environment depends on these tools.

So, let’s get started! Install the latest version of MinGW and MSYS from the MinGW official website. You can find the installers here (I used mingw-get-inst-20101030). Download the installer and save it inside the directory DOWNLOADS_DIR/mingw, then launch it.

  • When it asks for the installation path, you want to enter the path to your build dir (in my case, C:\gimp-win-beta\build). Make sure you don’t have a suffix of \MinGW to your path!
  • When it asks for components to install, you want: “C Compiler”, “C++ Compiler”, “MSYS Basic System”.

Now when we finished installing these, we want to start the shell (For windows users, shell=Command Line=Command Prompt=Terminal=Console=…). You can find the launcher for it it BUILD_DIR\msys\1.0\msys.bat – launch it and it should open a shell window (usually black with yellow/green text).

Tips:

  • Ctrl+C and Ctrl+V don’t work for copy paste, and you can’t select text just using the cursor. Instead, right click the window title (and not inside the actual window) and you’ll find inside the “Edit” entry the regular copy/paste commands
  • In order to mark text and copy it, right click the window title, choose Edit->Mark. Then select some text, and click Enter to copy it.

Now, it’s time to set the many environment variables. First of all, we have to set the path to GIMP_BETA_DIR. So type the following command (if the path to your GIMP_BETA_DIR is C:\gimp-win-beta)":

export GIMP_BETA_DIR=/C/gimp-win-beta

Now execute the following commands:

# Set paths to common directories
export DOWNLOADS_DIR=$GIMP_BETA_DIR/downloads
export BUILD_DIR=$GIMP_BETA_DIR/build
export MSYS_DIR=$BUILD_DIR/msys/1.0

# Now, this is the directory into we will install stuff (where / is the MSYS_DIR).
# You can change this to some other place, but there is no reason…
export INSTALL_PREFIX=/opt

# Now let’s acutally set the compilation/runtime variables
export PATH=$INSTALL_PREFIX/bin:$PATH
export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=$INSTALL_PREFIX/bin:$LD_LIBRARY_PATH
# C compiler flags
export CFLAGS=-I$INSTALL_PREFIX/include $CFLAGS
# C Pre-Processor flags
export CPPFLAGS=-I$INSTALL_PREFIX/include $CPPFLAGS
# Linker flags
export LIBS=-L$INSTALL_PREFIX/lib $LIBS

The smart reader probably noticed that windows folder seperators inside a path are ‘\’, while our paths contain ‘/’. That is because Unix/Linux paths use ‘/’ as the separators.

Wget

Wget is a fantastic utility which allows us to download files from the command line, and we are going to make heavy usage of it. The only problem is that we need to download Wget and we can’t do this from the command line :(

So, open up your favorite web-browser and get yourself a copy of Wget from the MSYS Wget download page (I used version 1.12-1). Note that you will need a library called OpenSSL for Wget to run – you can get it in the OpenSSL download page (I used version 1.0.0-1). Save both downloads under DOWNLOADS_DIR\mingw.

Now, as you may have noticed, we got files which had the suffix tar.lzma. Tar is an archive file which allows packing many files and folders together to one file, and Lzma is a compression method (The idea is similar to Zip – make things take less space). Don’t worry, MSYS came with a utility to extract these and we’ll use it right now! Inside the MSYS window you opened earlier, type:

lzma -dc $DOWNLOADS_DIR/mingw/wget-1.12-1-msys-1.0.13-bin.tar.lzma | tar -x -C /
lzma -dc $DOWNLOADS_DIR/mingw/libopenssl-1.0.0-1-msys-1.0.13-dll-100.tar.lzma | tar -x -C /

Note that you will need to replace the file names according to the version you downloaded. I’m not going to say this again every time – so from now on when you see commands with specific file name and versions, look around to find the matching ones that you have.

Compiling BABL

Download the latest version of babl from the babl website (I used version 0.1.2) and save it to $DOWNLOADS_DIR/src. You can do this from the command line by

# Create the src folder
mkdir $DOWNLOADS_DIR/src
# Enter the folder
cd $DOWNLOADS_DIR/src
# Download the file
wget ftp://ftp.gimp.org/pub/babl/0.1/babl-0.1.2.tar.bz2

Now, extract the source into the “home directory” (Which is actually located in MSYS_DIR/home/USERNAME) and enter the directory of the extracted source

mkdir ~/stable-sources
tar -xf $DOWNLOADS_DIR/src/babl-0.1.2.tar.bz2 -C ~/stable-sources
cd ~/stable-sources/babl-0.1.2

Now, let’s compile BABL as we would compile on Linux! Run

./configure --prefix=$INSTALL_PREFIX -C

Now, usually we would just type ‘make’ and ‘make install’, but this version (0.1.2) has a problem on windows due to an argument to the compiler which is unrecognized on windows (the argument is ‘-pthreads’). So, type:

#Replace 4 by the amount of jobs that you want to run, or simply remove the -j4 argument
make -j4

Now, it will probably fail with some errors. If it fails with some error about unrecognized option ‘-pthreads’ and something like ‘unresolved external symbol’/’can’t resolve symbol’, then type

make -j4 -k

This will tell make to “keep on going” even if some targets can’t be build (if you only had the error in what I suggested above, then it’s OK to ignore it. For other errors, don’t do this). Then type

make install -j4 -k

Many thanks for schumachl from the GIMP IRC for pointing out the -k tip.

Gtk+ and some utilities

The rest of the stuff we are going to build will depend on Gtk+, so let’s download it from the Gtk+ downloads page (I used version 2.22.1) – download the 32 bit version even on 64-bit machines (I didn’t try a 64-bit compilation). We will also need the packages called gettext-runtime (Run-time + Dev) and gettext-tools (Dev) from the same page.

# Make a directory to download Gtk+ components into
mkdir $DOWNLOADS_DIR/gtk
cd $DOWNLOADS_DIR/gtk
wget http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.1-20101227_win32.zip
wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime_0.18.1.1-2_win32.zip
wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-runtime-dev_0.18.1.1-2_win32.zip
wget http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/gettext-tools-dev_0.18.1.1-2_win32.zip

“But wait – these are zip files! How can we extract zip files from the command line?” We will need a utility called unzip to do that. So let’s get unzip from it’s download page (I used version 6.0.1) and extract it:

cd $DOWNLOADS_DIR/mingw # We want to save it in the MinGW downloads directory
wget http://downloads.sourceforge.net/project/mingw/MSYS/unzip/unzip-6.0-1/unzip-6.0-1-msys-1.0.13-bin.tar.lzma
lzma -dc $DOWNLOADS_DIR/mingw/unzip-6.0-1-msys-1.0.13-bin.tar.lzma | tar -x -C /

Now we can extract the Gtk+ packages:

unzip -qn $DOWNLOADS_DIR/gtk/gtk+-bundle_2.22.1-20101227_win32.zip
unzip -qn $DOWNLOADS_DIR/gtk/gettext-runtime_0.18.1.1-2_win32.zip
unzip -qn $DOWNLOADS_DIR/gtk/gettext-runtime-dev_0.18.1.1-2_win32.zip
unzip -qn $DOWNLOADS_DIR/gtk/gettext-tools-dev_0.18.1.1-2_win32.zip

Compiling GEGL

Now, we will compile GEGL in the same way we compiled BABL. Note that you can compile gegl from git, but this will require you to have Ruby installed. (I will cover this in the next version of the guide). So download the latest version of GEGL from it’s download area (I used version 0.1.2) and save it into $DOWNLOADS_DIR/src. Extract it and compile it like we did to BABL.

cd $DOWNLOADS_DIR/src
wget ftp://ftp.gimp.org/pub/gegl/0.1/gegl-0.1.2.tar.bz2
tar -xf $DOWNLOADS_DIR/src/gegl-0.1.2.tar.bz2 -C ~/stable-sources
cd ~/stable-sources/gegl-0.1.2
./configure --prefix=$INSTALL_PREFIX -C
make -j4
make install –j4

Perl, xsltproc and intltool

In order to compile GIMP, we will need intltool (an internationalization tool used for managing the translations). In order to run intltool, we will need Perl (a programming/scripting language). So let’s get them both!

We will use a distribution called Strawberry-Perl which is a Perl distribution to windows, which has everything we need. Download one of the portable-zip versions of strawberry perl from it’s download page (I used version 5.12.1.0, older version will cause problems!), and extract it into PERL_DIR (I told you I’ll explain what it’s needed for!).

cd $DOWNLOADS_DIR/perl
wget http://strawberryperl.com/download/5.12.1.0/strawberry-perl-5.12.1.0-portable.zip
# Let’s create a variable pointing to the perl directory
export PERL_DIR=$GIMP_BETA_DIR/perl
mkdir –p $PERL_DIR
cd $PERL_DIR
unzip -q $DOWNLOADS_DIR/perl/strawberry-perl-5.12.1.0-portable.zip

Now, here is the tricky part:

  • PERL_DIR/perl/bin contains the actual executable that we want to add to the path (perl.exe)
  • Some perl modules depend on libraries which are present at PERL_DIR/c/bin, so we need to add it to the path
  • There are libraries/executables in PERL_DIR/c/bin which have the same name as what we already have in the path and are using (for example, gcc)!

So, we need to add perl to the path carefully, in the following way:

# ok to put at the begining - only perl stuff is included
export PATH=$PERL_DIR/perl/bin:$PATH
# add this at the end, to get the perl dll's but without conflict with existing stuff
export PATH=$PATH:$PERL_DIR/c/bin

Now, Strawberry-Perl has an added bonus for us – inside $PERL_DIR/c/bin, it has a tool called xsltproc, which GIMP' needs for it’s compilation. One download less for us, since we got it already :)

Now, let’s get intltool, compile it(!) and install it. You can download it from the Gnome ftp (I used version 0.40.6).

# Make a directory for downloading build dependancies
mkdir $DOWNLOADS_DIR/build-deps
cd $DOWNLOADS_DIR/build-deps
wget ftp://ftp.gnome.org/pub/GNOME/sources/intltool/0.40/intltool-0.40.6.tar.bz2
tar -xf $DOWNLOADS_DIR/build-deps/intltool-0.40.6.tar.bz2 -C ~/stable-sources
cd ~/stable-sources/intltool-0.40.6
./configure && make -j4 && make install -j4

Note that we didn’t install to a special prefix (we didn’t pas a --prefix argument to configure). This is because we want to install it like a regular tool, and not as a part of our beta build.

Compiling GIMP (from package, not from git)

Now, it’s finally the time to compile GIMP! Note that we are going to compile without many plugins that have additional dependencies – getting some of these dependencies is explained below (if you want them, you’ll need to install them before compiling GIMP, or re-compile if you installed them after compiling GIMP). Let’s download GIMP (I used version 2.7.1) and extract it:

cd $DOWNLOADS_DIR/src
wget ftp://ftp.gimp.org/pub/gimp/v2.7/gimp-2.7.1.tar.bz2
tar -xf $DOWNLOADS_DIR/src/gimp-2.7.1.tar.bz2 -C ~/stable-sources
cd ~/stable-sources/gimp-2.7.1

Now, we are going to run GIMP’s configure script, with many flags that disable some plugins:

./configure --prefix=$INSTALL_PREFIX -C --disable-python --disable-gtk-doc  --without-libtiff --without-libjpeg --without-libmng --without-libexif --without-aa --without-libxpm --without-webkit --without-librsvg --without-print --without-poppler --without-gvfs --without-libcurl --without-wmf --without-libjasper --without-lcms --without-xmc --without-alsa --without-linux-input --without-dbus --without-hal --without-mac-twain

Yup, that’s a single line with many things to disable… I have underlined the ones which have instructions below on how to get their dependencies. Now run make and make install

make -j4
make install -j4

And you are done! You can now lunch gimp by running

gimp-2.7.exe

Now, we need something like the run-gimp.sh script that we created for the linux installation. In it we will save our environment variables which are required for some of the programs at runtime (and we will also be able to copy them back from there for general usage). This is left as homework for the reader! Simply collect all the export commands we did and put them in the file (in addition to the ones shown in the run-gimp.sh script above).

libexif

Libexif is a library which GIMP uses to read and write exif metadata for images. We can download and compile it in a way similar to the way we compiled other stuff:

mkdir $DOWNLOADS_DIR/libexif
cd $DOWNLOADS_DIR/libexif
wget http://downloads.sourceforge.net/project/libexif/libexif/0.6.20/libexif-0.6.20.tar.gz
tar -xf $DOWNLOADS_DIR/libexif/libexif-0.6.20.tar.gz -C ~/stable-sources
cd ~/stable-sources/libexif-0.6.20
./configure --prefix=$INSTALL_PREFIX && make -j4 && make install –j4

liblcms

LCMS – Little Color Management System, is a library which allows to handle color profiles and do some other color-related stuff. We can get it and compile it in a smilar way:

mkdir $DOWNLOADS_DIR/liblcms
cd $DOWNLOADS_DIR/liblcms
wget http://downloads.sourceforge.net/project/lcms/lcms/2.1/lcms2-2.1.tar.gz
tar -xf $DOWNLOADS_DIR/liblcms/lcms2-2.1.tar.gz -C ~/stable-sources
cd ~/stable-sources/lcms2-2.1
./configure --prefix=$INSTALL_PREFIX && make -j4 && make install –j4

libjpeg, libwmf, libtiff

  • libjpeg - Simply a library for reading/writing Jpeg image files.
  • libtiff - Simply a library for reading/writing Tiff image files.
  • libwmf - Simply a library for reading Wmf image files.

Luckily we can get a compiled versions of all these libraries, thanks to the GnuWin32 project!

#### libjpeg ####
mkdir $DOWNLOADS_DIR/libjpeg && cd $DOWNLOADS_DIR/libjpeg
wget http://gnuwin32.sourceforge.net/downlinks/jpeg-bin-zip.php
wget http://gnuwin32.sourceforge.net/downlinks/jpeg-dep-zip.php
wget http://gnuwin32.sourceforge.net/downlinks/jpeg-lib-zip.php
cd $INSTALL_PREFIX
for file in `ls -1 $DOWNLOADS_DIR/libjpeg`; do unzip -qn $DOWNLOADS_DIR/libjpeg/$file; done
#### libtiff (GEGL,GIMP) ####
mkdir $DOWNLOADS_DIR/libtiff && cd $DOWNLOADS_DIR/libtiff
wget http://gnuwin32.sourceforge.net/downlinks/tiff-bin-zip.php
wget http://gnuwin32.sourceforge.net/downlinks/tiff-dep-zip.php
wget http://gnuwin32.sourceforge.net/downlinks/tiff-lib-zip.php
cd $INSTALL_PREFIX
for file in `ls -1 $DOWNLOADS_DIR/libtiff`; do unzip -qn $DOWNLOADS_DIR/libtiff/$file; done
#### libwmf ####
mkdir $DOWNLOADS_DIR/libwmf && cd $DOWNLOADS_DIR/libwmf
wget http://gnuwin32.sourceforge.net/downlinks/libwmf-dep-zip.php
wget http://gnuwin32.sourceforge.net/downlinks/libwmf-bin-zip.php
wget http://gnuwin32.sourceforge.net/downlinks/libwmf-lib-zip.php
cd $INSTALL_PREFIX
for file in `ls -1 $DOWNLOADS_DIR/libwmf`; do unzip -qn $DOWNLOADS_DIR/libwmf/$file; done

librsvg

Todo…


Compiling GIMP 2.7 on Windows (from Git)

Todo…

24 comments:

  1. wrong link
    http://lightningismyname.blogspot.com/p/compiling-gimp.html

    ReplyDelete
  2. @andreasp: No problem ;)
    btw, What wrong link? I checked the link to this page all over my site, and I didn't find any broken version...

    ReplyDelete
  3. Great tutorial :).
    I often had trouble with the environment variables (never knew when/how to use them - I'm lucky that at the moment, the git versions of gegl/gimp do not conflict with the versions available from debian unstable, even without using env variables).
    These instructions clear things up. :)

    For the sake of completeness, maybe you could add the "git pull" commands (and possible make uninstall/make clean) so that people will figure out how to update their build?

    ReplyDelete
  4. @Rore: Glad this tutorial helped you :)
    Yeah, I probably should add some information on updating the build - I'll update the guide later today.

    ReplyDelete
  5. Is there a typo in:
    export CLAGS=-I$INSTALL_PREFIX/include $CFLAGS
    should it not be export CFLAGS?

    Tutorial is great, except I can't get passed compiling GEGL. I get an error about the packaging of BABL during configure.

    checking for BABL... configure: error: in `/home/niel/stable-sources/gegl-0.1.2':
    configure: error: The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config.
    There *is* a file in /opt/lib/pkconfig called 'babl.pc' and I did set the environment variable as you describe (export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH)

    ReplyDelete
  6. 1. Fixed the typo - it indeed should be CFLAGS :)

    2. That is odd - this error message means you don't have the pkg-config toool installed, or you have a too old version of it. It is possible *theoretically* to compile GIMP without it, but so many things will break that I doubt it's worth the effort. Can you install/update the pkg-config tool from your package manager?

    ReplyDelete
  7. Hmm, I don't think I can install/update the pkg-config. I was following your Windows instructions, and assume pkg-config is part of the MinnGW installation.

    ReplyDelete
  8. @Anonymous: You can get pkg-config with gtk+. Make sure you download the "all in one" gtk+ bundles, and these will contain pkg-config.
    Just make sure that the bin directory of the gtk+ installation is on your path (this should be the case if you install gtk to the root mingw/msys installation directory).

    ReplyDelete
  9. Hi again. I added the GTK bundle to the msys/1.0 directory. This allowed me to get further into the configure phase, but it pkg-config choked on a trailing ':' in its path. Removed that and managed to start a make, but I have errors from libpng14 referring to a missing zlib.h. The irony is, zlib.h does exist in msys/1.0/include. Manually changinging the include in png.h to ../zlib.h fixed that.

    ReplyDelete
  10. Configuring gimp failed because of the GEGL package not being found. Fixed that by copying the gegl.rc and gegl.rc.in files to the pkg-config directory. I was surprised it hadn't done that as the BABL package did.
    make stops with:
    Creating library file: .libs/libgimp-2.0.dll.a
    .libs/gimp.o:gimp.c:(.text+0x4c0): undefined reference to `libintl_setlocale'
    which I'm not able to fix :-(

    ReplyDelete
  11. Hi, I found you don't actually need to install Strawberry perl because msys has a shipped one. In the mingw installer they attach perl 5.6 which is a bit outdated to compile gimp but when you do
    mingw-get update
    mingw-get upgrade msys-perl
    you'll automagically get a working 5.8 perl which is not the newest one but new enough to compile GIMP :)

    ReplyDelete
  12. @mc: Wow, this sounds promising. I will try to check it out, along with the other updates that need to be done for this guide.

    Thanks for the tip, I will verify it works for me and then I'll update it :)

    ReplyDelete
  13. Thats really a great tutorial. i have done all the steps that you have told to compile GIMP in windows. My aim is not to use GIMP but GEGL and babl libraries for image manipulation in visual studio 2010 for android. after doind the above steps, what changes i need to make in the "project properties" to create a project in visual studio. how can i run a simple project using GEGL library functions?

    ReplyDelete
  14. Hi,
    This is a great tutorial. i also thank you for replying my question in stackoverflow.
    now, i have followed all the steps that you have said to compile GIMP in windows. i need to use the gegl and babl libraries for image processing in visual studio 2010 and then convert it for android. what changes i need to make in the project properties of visual studio project to run a simple program in C using gegl libraries?

    ReplyDelete
  15. Also, I cannot use wget to download files. i get an error: msys-intl-8.dll missing. what is the problem?

    ReplyDelete
  16. after installing the GEGL and Babl... where are the lib files? which directory i need to add for the lib files?

    ReplyDelete
  17. for GEGL, i need libjpeg. i have downloaded it at C:\gimp-win-beta\downloads\libjpeg. but in which directory i have unzip them?

    ReplyDelete
  18. @Sayak: Hi,
    The files mingw generates are not regular visual studio library files, but special library files whic are suited for use with it. See http://www.mingw.org/wiki/CreateImportLibraries

    There are instructions about where to extract libjpeg at the bottom of this tutorial in the GIMP part - it has additional information regarding building with additional library support

    Regarding wget, in the MSYS wget page (linked above) there is a readme file which lists dependancies (see RELEASE_NOTES.txt). Browse around the download area to find these additional dependancies if missing.

    Finally, creating an MSVC project should be trivial once you have the DLLs (and LIBS) as explained above.

    ReplyDelete
  19. when trying to compile GEGL, i am having this error...
    $ make -j4
    make all-recursive
    make[1]: Entering directory `/home/stable-sources/gegl-0.1.2'
    Making all in gegl
    make[2]: Entering directory `/home/stable-sources/gegl-0.1.2/gegl'
    Making all in buffer
    make[3]: Entering directory `/home/stable-sources/gegl-0.1.2/gegl/buffer'
    CC gegl-tile-backend-tiledir.lo
    CC gegl-buffer.lo
    CC gegl-buffer-access.lo
    CC gegl-buffer-share.lo
    In file included from gegl-buffer-share.c:25:0:
    ../../gegl/gegl.h:23:23: fatal error: babl/babl.h: No such file or directory
    compilation terminated.
    make[3]: *** [gegl-buffer-share.lo] Error 1
    make[3]: *** Waiting for unfinished jobs....
    In file included from gegl-buffer-access.c:29:0:
    ../../gegl/gegl.h:23:23: fatal error: babl/babl.h: No such file or directory
    compilation terminated.
    In file included from gegl-buffer.c:49:0:
    ../../gegl/gegl.h:23:23: fatal error: babl/babl.h: No such file or directory
    compilation terminated.
    make[3]: *** [gegl-buffer.lo] Error 1
    make[3]: *** [gegl-buffer-access.lo] Error 1
    In file included from gegl-tile-backend.h:22:0,
    from gegl-tile-backend-tiledir.c:26:
    gegl-tile-source.h:23:23: fatal error: babl/babl.h: No such file or directory
    compilation terminated.
    make[3]: *** [gegl-tile-backend-tiledir.lo] Error 1
    make[3]: Leaving directory `/home/stable-sources/gegl-0.1.2/gegl/buffer'
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/stable-sources/gegl-0.1.2/gegl'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/stable-sources/gegl-0.1.2'
    make: *** [all] Error 2

    ReplyDelete
  20. When configuring gegl-0.1.2, I receive the error:

    checking for BABL... configure: error: Package requirements (babl >= 0.1.2) were
    not met:

    No package 'babl' found

    Is this because babl used babl-0.1 for its file names and directories when installing? (I downloaded babl-0.1.2)

    ReplyDelete
  21. Great writeup. I was flowing nicely through the MinGW procedure until I went to configure GEGL.

    I get the same error as the Anonymous with the missing/outdated pkg-config. Exact error message:
    """
    The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config.

    Alternatively, you may set the environment variables BABL_CFLAGS and BABL_LIBS to avoid the need to call pkg-config.
    """

    This is curious, because I can find the following (hopefully) pertinent directories:
    1) /opt/lib/pkgconfig which contains babl.pc
    2) c:/gimp-win-beta/downloads/mingw/bin which contains pkg-config.exe

    I've tried just about every permutation of PKG_CONFIG_PATH I can think of, but none of them allow me to configure GEGL 0.1.6 nor GEGL 0.1.2.

    Was anyone able to get anywhere on this?

    ReplyDelete
  22. @Clay: Sorry for the delay in my answer. Are you sure you downloaded the gtk all in one bundle? It should include a program called pkg-config.exe inside it's bin directory. That is what the installation is looking for. If you do have pkg-config.exe, tell me and also check it's version (run pkg-config.exe --version).

    Also, I really should update parts of this post. When my GSoC is over, I'll try doing that.

    ReplyDelete
  23. I keep getting this error when running make -j4 on gegl.
    as you can see i used version 0.1.8 instead of the one used here.
    libintl.h is located in the folder C:\gimp-win-beta\build\msys\1.0\include but

    I tried adding "C:\gimp-win-beta\build\msys\1.0\" and "C:\gimp-win-beta\build\msys\1.0\include" to PATH but it didn't help.

    I didn't have any issues with BABL

    this is the last bit of the ./configure... command

    Building GEGL with prefix=/opt

    Optional features:
    GEGL docs: yes
    Build workshop: no
    Build website: no (asciidoc not found)
    SIMD: sse:yes mmx:yes
    Vala support: no (vapigen executable not found)

    Optional dependencies:
    asciidoc: no (asciidoc not found)
    enscript: no (enscript not found)
    Ruby: no
    Lua: no (usable lua not found)
    Cairo: yes
    Pango: yes
    pangocairo: yes
    GDKPixbuf: yes
    JPEG: yes
    PNG: yes
    OpenEXR: no (OpenEXR library not found)
    rsvg: no (usable librsvg not found)
    SDL: no (SDL library not found)
    openraw: no (openraw library not found)
    Jasper: no (jasper library not found)
    graphviz: no (graphviz not found)
    avformat: no (libavformat not found)
    V4L: no
    spiro: no (usable SPIRO library not found)
    EXIV: no (exiv2 library not found)
    umfpack: no (usable umfpack library not found)

    this is the last bit of the make -j4 command

    make[3]: Leaving directory `/home/marco/stable-sources/gegl-0.1.8/gegl/graph'
    Making all in module
    make[3]: Entering directory `/home/marco/stable-sources/gegl-0.1.8/gegl/module'
    CC gegldatafiles.lo
    CC geglmodule.lo
    CC geglmoduledb.lo
    gegldatafiles.c: In function 'gegl_path_parse':
    gegldatafiles.c:87:17: warning: variable 'home' set but not used [-Wunused-but-s
    et-variable]
    In file included from geglmodule.c:24:0:
    C:/gimp-win-beta/build/msys/1.0/include/glib-2.0/glib/gi18n-lib.h:25:21: fatal e
    rror: libintl.h: No such file or directory
    compilation terminated.
    make[3]: *** [geglmodule.lo] Error 1
    make[3]: *** Waiting for unfinished jobs....
    make[3]: Leaving directory `/home/marco/stable-sources/gegl-0.1.8/gegl/module'
    make[2]: *** [all-recursive] Error 1
    make[2]: Leaving directory `/home/marco/stable-sources/gegl-0.1.8/gegl'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/marco/stable-sources/gegl-0.1.8'
    make: *** [all] Error 2

    marco@marco-PC ~/stable-sources/gegl-0.1.8
    $

    any help will be appreciated

    ReplyDelete