Building GIMP
This page describes how to build GIMP.
Prerequisites
You should know how to use:
- a terminal and the command line;
- shell environment variables.
GIMP’s dependencies
GIMP depends on quite a few libraries. For complete list of dependencies, if you’re interested, see the files:
These text files are generated by our build system and contain up-to-date
version information for dependencies. They are included in the root folder of
source tarballs under the name INSTALL
.
Build system
Preparing for Building
- You may need to install some software to build GIMP, including a C compiler, make, GNU autotools, meson, and more, plus many dependencies. See the OS-specific pages for details:
- build/linux - Building GIMP on Linux
- build/macos - Building GIMP on macOS
- build/windows - Building GIMP on Windows
- Choose a place to install everything, and set a variable to point to it:
If you’re building GIMP from master, you may not want to install it in your system prefix, as you may break your system GIMP installation, or get odd behavior, especially if you also have a system version of GIMP installed.
You should then create another prefix directory where GIMP (and some dependencies) may be installed safely. On Linux you could use $HOME/.local
. Let’s name your custom prefix :
export GIMP_PREFIX=${HOME}/_install
- Set some environment variables:
Some dependencies may be installed in this prefix too, so the build system should be able to find them :
# Used to find programs/tools during build
export PATH="${GIMP_PREFIX}/bin:$PATH"
# Assuming that you have toolchain installed
# If this don't work, so manually set the dirs
LIB_DIR=$(cc -print-multi-os-directory | sed 's/\.\.\///g')
cc -print-multiarch | grep . && LIB_SUBDIR=$(echo $(cc -print-multiarch)'/')
# Used to detect the build dependencies
export PKG_CONFIG_PATH="${GIMP_PREFIX}/${LIB_DIR}/${LIB_SUBDIR}pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
# Used to find the libraries at runtime
export LD_LIBRARY_PATH="${GIMP_PREFIX}/${LIB_DIR}/${LIB_SUBDIR}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
# Used to find the glib-introspection dependencies
export XDG_DATA_DIRS="${GIMP_PREFIX}/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}"
# Used to find introspection files
export GI_TYPELIB_PATH="${GIMP_PREFIX}/${LIB_DIR}/${LIB_SUBDIR}girepository-1.0${GI_TYPELIB_PATH:+:$GI_TYPELIB_PATH}"
# Used by Autotools to find its tools
export ACLOCAL_FLAGS="-I $GIMP_PREFIX/share/aclocal $ACLOCAL_FLAGS"
Download the source code
The sources needed to compile GIMP can be cloned or downloaded here.
You need to be used to at least managing branches before building. Take a look at this comprehensive page.
Build the source code
babl and GEGL
Babl and GEGL use Meson. The build needs to be out-of-source, but the process is simple.
You can read the file meson_options.txt
to find a list of options. Here’s the process:
mkdir babl/_build && cd babl/_build
meson setup .. -Dprefix="${GIMP_PREFIX}"
ninja && ninja install
Then repeat for GEGL.
GIMP
Finally, you’re ready to build GIMP!
For the stable branch (gimp-2-10
for GIMP 2.10.x versions), you must build with autotools.
For the unstable branch (master
for GIMP 2.99 versions which will lead
to future stable GIMP 3.0 branch), you must build with Meson.
Autotools build
The steps are the very common historical build process, refered to as
./configure && make && make install
, except that ./autogen.sh runs
./configure for you.
cd into the directory where you unpacked gegl.
If you’re building source you checked out from git, run:
./autogen.sh --prefix=${GIMP_PREFIX}
(assuming, as recommended, you have chosen to install outside the usual place, and defined environment variable GIMP_PREFIX
)
This generates a configure script and then runs it.
If you’re building from a tarball, use configure instead of autogen:
./configure --prefix=${GIMP_PREFIX}
To see options you can configure:
./configure --help
(for a first build, it may be easier to accept the default build configuration, then later tweak the configuration in steps)
Then:
make && make install
Note: it is also possible to build autotools out-of-tree, calling the
configure
script from another directory, i.e.:
mkdir _build && cd _build
../configure --prefix=${GIMP_PREFIX} && make && make install
Meson build
You can configure the build with options.
Options for the meson build of GIMP are described in the repository file meson_options.txt.
Meson itself also provides built-in options, such as :
buildtype=debug|debugoptimized|release
: Predefined compiler properties for each purposewarning_level=[1, 2, 3]
: The level of compiler warningsb_lto=true|false
: Enable link-time optimizationsb_coverage=true|false
: Enable coverage tools.b_pgo=off|generate|use
: Enable profile guided optimizationsb_sanitize=none|address|thread|undefined|memory|address,undefined
: Use a code sanitizer
Here’s the process:
mkdir gimp/_build && cd gimp/_build
meson setup .. -Dprefix="${GIMP_PREFIX}"
ninja && ninja install
Useful build options
You can customize the directory where GIMP stores settings. This prevents any interference with other GIMP installations on the same computer.
- Autotools build :
–with-gimpdir=GIMP/git-master
- Meson build :
-Dgimpdir=GIMP/git-master
Problems?
Most problems will occur during the configure stage, and with any luck it’s just a missing package and the error message will make it clear what package you need. But there are more subtle problems that can occur. If you have a difficult error, look in: Problems and Solutions
Running Your New GIMP
To run frequently the GIMP you have installed outside the usual places, you need
to keep defined the same variables
as for the build. In particular PATH
and LD_LIBRARY_PATH
, which affect runtime.
To keep those variables contained only for the execution of GIMP, you may want to use subshells :
(source ~/gimp_definitions.sh ; $GIMP_PREFIX/bin/gimp-X.XX)
Or, you may want to set some of these variables in your profile (a shell script
that sets environment variables when you login, e.g. $HOME/.bash_profile
).
See the OS-specific pages for more specific advice:
- build/linux - Building GIMP on Linux
- build/macos - Building GIMP on macOS
- build/windows - Building GIMP on Windows