Hacking:Building with Meson

From GIMP Developer Wiki
Revision as of 23:30, 3 November 2019 by Ankh (Talk | contribs)

Jump to: navigation, search

This page is intended to replace the content of Hacking:Building when the Meson MR is merged.


This page is a guide to build Gimp with the new Meson build system.

Define the installation prefix

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.

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 :


Some dependencies may be installed in this prefix too, so the build system should be able to find them :

# Used to detect the build dependencies
export PKG_CONFIG_PATH="${GIMP_PREFIX}/lib/pkgconfig:${GIMP_PREFIX}/share/pkgconfig"

# Used to find the glib-introspection dependencies
# Used to find the libraries at runtime

Note: if you don't include the default value of XDG_DATA_DIRS, you may get a compile error trying to read a PNG icon file. You could try using this in that case:

export XDG_DATA_DIRS="${GIMP_PREFIX}/share:/usr/local/share:/usr/share"

Install the dependencies

Most dependencies from Gimp are available to install with your package manager.

Babl and Gegl are two special cases : if you're building Gimp from master, you need to build them too as they are tightly linked.

Depending on the OS or distro you're using, the package names may be different. Here are widely-used dependency install commands:

Archlinux and derivatives

pacman -S --needed


apt install

Windows / MinGW

pacman -S --needed

Download the source code

Download with git

git clone https://gitlab.gnome.org/GNOME/babl.git
git clone https://gitlab.gnome.org/GNOME/gegl.git
git clone https://gitlab.gnome.org/GNOME/gimp.git

If your distro does not provide them, you should get the Mypaint libs too :

git clone https://github.com/mypaint/mypaint-brushes.git
git clone https://github.com/mypaint/libmypaint.git

Download release archives

Gimp also provides release archives :


Releases for mypaint can be found on their github page.

Build the code


For both Libmypaint an Mypaint-brushes, use Autotools to install :

cd libmypaint

# Generate the configure script. That may be unnecessary with release archives :

# Configure the build (you can call ./configure --help):
./configure --prefix=${GIMP_PREFIX}

# Build the code :
make -j$(nproc) install

cd ..


Babl and Gegl use Meson. The build needs to be out-of-source, but the process is simplified.

You can read the file meson_options.txt to find a list of options.

You may enable Link-time optimization (meson option b_lto)to have better performance.

cd babl
meson _build \
    --prefix=${GIMP_PREFIX} \
    --buildtype=release \

cd _build
ninja install

And the same for Gegl :

cd gegl
meson _build \
    --prefix=${GIMP_PREFIX} \
    --buildtype=release \

cd _build
ninja install


Numerous options are available to configure the build.

You should read the file meson_options.txt to know the options specific to this project. Meson also provides some useful options, such as :

  • warning_level=[1, 2, 3] : The level of compiler warnings
  • b_lto=true|false : Enable link-time optimizations
  • b_coverage=true|false : Enable coverage tools.
  • b_pgo=off|generate|use : Enable profile guided optimizations
  • b_sanitize=none|address|thread|undefined|memory|address,undefined : Use a code sanitizer

cd gimp
meson _build \
    --prefix=${GIMP_PREFIX} \
    --buildtype=release \
    -Djavascript=always \
    -Dlua=always \

cd _build
ninja install