Hacking:Building

From GIMP Developer Wiki
Revision as of 14:54, 3 September 2019 by Akkana (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page contains things that you should know in order to build GIMP.

GIMP's dependencies

Gimp depends on quite a few libraries, including but not limited to:

  • GLib – a library used by many gnome applications, containing utilities and common data structures for programs written in C.
  • GObject - a library for implemnting objects (as in Object-Oriented-Programming) in C.
  • GTK+ – a graphical toolkit for building cross-platform user interfaces. GIMP 2.99 and later need GTK 3.0.
  • Cairo – a 2D graphics library, used for drawing some of GIMP’s widget and also used by Gtk+.
  • Python-Cairo: Python bindings for Cairo
  • Pango – a library for laying out and rendering text, used also in Gtk+.
  • MyPaint - a painting library that allows a lot of flexibility for brushes; it needs both libmypaint (the libmypaint-v1 branch) and mypaint-brushes (the v1.3.x branch).

GIMP's core depends also on two libraries which are mainly (but not only) intended to be used with GIMP:

  • 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.
To build GIMP 2.10, you need the GEGL version from git branch 'gegl-0-4'.
To build GIMP master (= the development version of GIMP), you need the GEGL version from git branch 'master'.

Some of GIMP's plugins depend on (at least) the following libraries

  • librsvg – a library for rendering SVG files.
  • libpng – a library for reading and writing PNG image files. Used by Gtk+, GIMP and GEGL.
  • libexif - a library for manipulating exif data (image metadata).
  • libwmf - a library for working with WMF files.
  • libtiff - a library for reading and writing TIFF image files.
  • libjpeg - a library for reading and writing JPEG image files.
  • liblcms - the Little Color Management System, a library for working with color profiles.

This list is incomplete.

See also the file INSTALL (or INSTALL.in in GIMP master).

Build system

Building from a Tarball vs. building from latest source (Git)

There are two ways to get the source. Releases are usually packaged in a tar archive or "tarball", which will usually have an extension like .tar, .tar.gz, tar.bz2. You can download tarballs from:

http://download.gimp.org/pub/babl/
http://download.gimp.org/pub/gegl/
http://download.gimp.org/pub/gimp/

You can also check out the source using the version control system Git. This is the only way to get the most up-to-date development release, but you can also see older releases (using branches). Building from git is slightly different from building from a tarball.

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:

1. Choose a place to install everything, and set a variable to point to it:

export INSTALL_PREFIX=$HOME/gimp-git

It's very important that you choose an install prefix, and not just let it install to /usr/local or wherever! If you do that, you will probably see odd behavior, especially if you also have a system version of GIMP installed.

2. Create that directory, and a "share" subdirectory:

mkdir -p $INSTALL_PREFIX/share

3. Set some environment variables:

Here's an example of setting environment variables for the build, though the exact values will vary according to your OS, distro and other factors (Linux users, see the Linux build page Hacking:Building/Linux for some examples). You may need to run meson and autogen.sh/configure several times to nail them all down.

export PATH="$INSTALL_PREFIX/bin:$PATH"
export PKG_CONFIG_PATH="$INSTALL_PREFIX/lib/pkgconfig:$INSTALL_PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$INSTALL_PREFIX/lib:$LD_LIBRARY_PATH"
export ACLOCAL_FLAGS="-I $INSTALL_PREFIX/share/aclocal $ACLOCAL_FLAGS"

GIMP build used to look for a file named $INSTALL_PREFIX/share/config.site and run it automatically, so many people used that as a place to define their environment variables. Now, with meson builds, config.site is no longer run automatically, so you'll have to do that step by hand.

You may see examples that also set the variable XDG_DATA_DIRS. Don't. Doing so will confuse gdk-pixbuf and may lead to build failures with messages like "Couldn't recognize the image file format".

Check Out the Source

Clone from 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

Or get tarballs from:

http://download.gimp.org/pub/babl/
http://download.gimp.org/pub/gegl/
http://download.gimp.org/pub/gimp/

Additional Git Requirements

To Build Git Master, You Also Need:

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

Build libmypaint and mypaint-brushes

cd into the directory where you unpacked libmypaint. Make sure you have the *libmypaint-v1* branch checked out:

If you're building source you checked out from git, run:

./autogen.sh

This generates a configure script. If you're building from a tarball, you should already have a configure script and can skip that step.

If you think you might want to set any special options, you can now run ```./configure --help``` to see what's available.

Then:

./configure --prefix=INSTALL_PREFIX

Check the output to make sure you aren't missing any features you might want. Then:

make && make install

Then repeat for mypaint-brushes.

Build babl and gegl

Babl and gegl now use meson/ninja as their build system. Build babl this way:

cd babl
SRCDIR=$(pwd)
BUILD_DIR=$SRCDIR/obj-$(arch)
mkdir -p $BUILD_DIR
cd $BUILD_DIR
meson -Dprefix=$INSTALL_PREFIX $SRCDIR && ninja && ninja install

Then repeat for gegl.

Build gimp

Finally, you're ready to build gimp! The steps are similar to that for libmypaint, 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=INSTALL_PREFIX

This generates a configure script and then runs it.

If you're building from a tarball, use configure instead of autogen:

./configure --prefix=INSTALL_PREFIX

You can run ```./configure --help``` if you want to see special options you can configure.

Check the output to make sure you aren't missing any features you might want. Then:

make && make install

Repeat the same steps for gimp.

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:

Hacking:Problems_and_solutions

Running Your New GIMP

You will probably need to set some environment variables in order to run the gimp you just built. In addition to the variables you used for the build, you may need

export XDG_DATA_DIRS=$GIMP_PREFIX/share:$XDG_DATA_DIRS

See the OS-specific pages for more specific advice: