How to Compile GIMP from Git Using Meson and Ninja

This guide provides a straightforward walkthrough for compiling the latest development version of the GNU Image Manipulation Program (GIMP) directly from source using Git, Meson, and Ninja. You will learn how to prepare an isolated build environment, install necessary build tools, compile the core dependencies (babl and GEGL), and build and launch GIMP without interfering with any version provided by your operating system's package manager.

1. Install Required Build Tools and Dependencies

Before compiling, install Git, Meson, Ninja, a C/C++ compiler, and the base development libraries required by GIMP and its dependencies.

On Debian, Ubuntu, or derivative distributions, install the base tools with:

sudo apt update
sudo apt install git meson ninja-build build-essential pkg-config \
    libgtk-3-dev libglib2.0-dev liblcms2-dev libjson-glib-dev \
    libgexiv2-dev libmypaint-dev mypaint-brushes librsvg2-dev \
    libpoppler-glib-dev libraw-dev libtiff-dev libjpeg-dev \
    libpng-dev libwebp-dev libopenexr-dev python3 python3-pip

On Fedora:

sudo dnf install git meson ninja-build gcc gcc-c++ pkgconf-pkg-config \
    gtk3-devel glib2-devel lcms2-devel json-glib-devel libgexiv2-devel \
    libmypaint-devel mypaint-brushes librsvg2-devel poppler-glib-devel \
    LibRaw-devel libtiff-devel libjpeg-turbo-devel libpng-devel \
    libwebp-devel OpenEXR-devel python3

2. Configure the Isolated Environment

To keep the development build separated from your stable system, build everything into a dedicated prefix directory (such as $HOME/gimp-prefix).

Create an environment setup script named setup-env.sh:

export PREFIX="$HOME/gimp-prefix"
export PATH="$PREFIX/bin:$PATH"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/lib64/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$PREFIX/lib:$PREFIX/lib64:$LD_LIBRARY_PATH"
export XDG_DATA_DIRS="$PREFIX/share:$XDG_DATA_DIRS"
export GI_TYPELIB_PATH="$PREFIX/lib/girepository-1.0:$PREFIX/lib64/girepository-1.0:$GI_TYPELIB_PATH"

Source the script in your terminal before building or running GIMP:

source setup-env.sh

Create a working directory for the source code:

mkdir -p "$HOME/gimp-source"
cd "$HOME/gimp-source"

3. Clone and Build babl

GIMP relies on the babl pixel encoding library. You must compile the latest git version.

git clone https://gitlab.gnome.org/GNOME/babl.git
cd babl
meson setup _build --prefix="$PREFIX" -Dbuildtype=debugoptimized
ninja -C _build
ninja -C _build install
cd ..

4. Clone and Build GEGL

GEGL (Generic Graphics Library) is GIMP's primary image processing engine.

git clone https://gitlab.gnome.org/GNOME/gegl.git
cd gegl
meson setup _build --prefix="$PREFIX" -Dbuildtype=debugoptimized
ninja -C _build
ninja -C _build install
cd ..

5. Clone and Build GIMP

Now clone the main GIMP repository, configure the build using Meson, and compile it with Ninja.

git clone https://gitlab.gnome.org/GNOME/gimp.git
cd gimp
meson setup _build --prefix="$PREFIX" -Dbuildtype=debugoptimized
ninja -C _build
ninja -C _build install
cd ..

Note: If meson setup reports missing optional or required libraries, install the corresponding -dev or -devel package via your system package manager and re-run the setup command.

6. Launch the Compiled GIMP

To run your custom-built GIMP, ensure your custom environment variables are active and execute the binary from your prefix:

source setup-env.sh
gimp-2.99

(Note: Depending on the Git branch, the executable name might be gimp-2.99, gimp-3.0, or simply gimp located within $PREFIX/bin/.)