Difference between revisions of "Hacking:Building"

From GIMP Developer Wiki
Jump to: navigation, search
(GIMP's dependencies)
(Major rewrite: update the instructions to reflect what's needed now, and try to make the page simpler and more succinct.)
Line 1: Line 1:
<div style="color:red">This page is a work in progress!!
 
It's based on [http://lightningismyname.blogspot.com/p/compiling-gimp.html this page]</div>
 
 
This page contains things that you should know in order to build GIMP.
 
This page contains things that you should know in order to build GIMP.
 
__TOC__
 
__TOC__
 +
 
== GIMP's dependencies ==
 
== GIMP's dependencies ==
Gimp depends on the following common libraries for it's core:
+
Gimp depends on the following common libraries for its core:
 
* [[Wikipedia:GLib|GLib]] – a library used by many gnome applications, containing utilities and common data structures for programs written in C.  
 
* [[Wikipedia:GLib|GLib]] – a library used by many gnome applications, containing utilities and common data structures for programs written in C.  
 
* [[Wikipedia:GObject|GObject]] - a library for implemnting objects (as in Object-Oriented-Programming) in C.
 
* [[Wikipedia:GObject|GObject]] - a library for implemnting objects (as in Object-Oriented-Programming) in C.
Line 11: Line 10:
 
* Python-Cairo: Python bindings for Cairo
 
* Python-Cairo: Python bindings for Cairo
 
* [[Wikipedia:Pango|Pango]] – a library for laying out and rendering text, used also in Gtk+.
 
* [[Wikipedia:Pango|Pango]] – a library for laying out and rendering text, used also in Gtk+.
 +
* [[Wikipedia:MyPaint|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:
 
GIMP's core depends also on two libraries which are mainly (but not only) intended to be used with GIMP:
 +
* [[Wikipedia:GEGL#babl|babl]] – a library for converting between pixel formats, heavily used by GIMP when communicating with GEGL.
 
* [[Wikipedia:GEGL|GEGL]] – a graph based image processing library, heavily used in GIMP’s core.
 
* [[Wikipedia: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 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'.
 
:To build GIMP master (= the development version of GIMP), you need the GEGL version from git branch 'master'.
* [[Wikipedia:GEGL#babl|babl]] – a library for converting between pixel formats, heavily used by GIMP when communicating with GEGL.
 
 
GIMP also needs For MyPaint brushes, libmypaint. he libmypaint repository is hosted at: https://github.com/mypaint/libmypaint
 
 
If installing from repository, do not install the master branch! Checkout the tag "v1.3.0" instead, or simply install from a tarball or from your favorite package manager.
 
 
We also need the mypaint-brushes data package:https://github.com/mypaint/mypaint-brushes. If installing from repository, install from branch "v1.3.x" or the particular tag "v1.3.0". In particular do not install from master
 
which installs brushes incompatible with GIMP.
 
Also this is a data packages and therefore it will install the
 
pkg-config file inside `$PREFIX/share/pkgconfig/`. If you install
 
mypaint-brushes from repository in a non-standard prefix, you will
 
have to make sure your $PKG_CONFIG_PATH environment variable also
 
lists `$PREFIX/share/pkgconfig/`.
 
  
 
Some of GIMP's plugins depend on (at least) the following libraries
 
Some of GIMP's plugins depend on (at least) the following libraries
Line 38: Line 26:
 
* [http://libjpeg.sourceforge.net/ libjpeg] - a library for reading and writing [[Wikipedia:JPEG|JPEG]] image files.
 
* [http://libjpeg.sourceforge.net/ libjpeg] - a library for reading and writing [[Wikipedia:JPEG|JPEG]] image files.
 
* [http://www.littlecms.com/ liblcms] - the Little Color Management System, a library for working with color profiles.
 
* [http://www.littlecms.com/ liblcms] - the Little Color Management System, a library for working with color profiles.
 +
This list is incomplete.
  
 
+
See also the file [https://gitlab.gnome.org/GNOME/gimp/blob/gimp-2-10/INSTALL.in INSTALL] (or INSTALL.in in GIMP master).
See also the file [https://gitlab.gnome.org/GNOME/gimp/blob/gimp-2-10/INSTALL.in INSTALL].
+
In GIMP master these informations are in the file [https://gitlab.gnome.org/GNOME/gimp/blob/master/INSTALL.in INSTALL.in] - expect to have to build GIMP first to then know the necessary dependencies for building GIMP ...
+
  
 
== Build system ==
 
== Build system ==
 
=== Building from a Tarball vs. building from latest source (Git) ===
 
=== Building from a Tarball vs. building from latest source (Git) ===
There are 2 types of build we can do:
+
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:
* A build from Tarball - Tarballs (or in short, TARs) are files which pack together many folders and files, and the term of building from a Tarball refers to building from a package of code that you download from the program's website, for an official release of the program.
+
You can download tarballs from:
+
 
<pre>http://download.gimp.org/pub/babl/
 
<pre>http://download.gimp.org/pub/babl/
 
http://download.gimp.org/pub/gegl/
 
http://download.gimp.org/pub/gegl/
http://download.gimp.org/pub/gimp/</pre>
+
http://download.gimp.org/pub/gimp/
* A build from Git - The latest source of programs is hosted in a version control system (in our case, the version control is called Git) and you can download the updated source directly from these. The source there is the most up-to-date, and it's sometimes unstable.
+
</pre>
It matters to us, in the fact that building from Git requires an additional step (detailed below) and it usually requires more tools.
+
 
You can check out the git sources from:
+
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.
<pre>git clone git@gitlab.gnome.org:GNOME/babl.git
+
 
git clone git@gitlab.gnome.org:GNOME/gegl.git
+
== Preparing for Building ==
git clone git@gitlab.gnome.org:GNOME/gimp.git</pre>
+
 
 +
You may need to install some build tools to build GIMP, including a C compiler, make, GNU autotools, meson and more. See the OS-specific pages for details:
 +
* [[Hacking:Building/Linux]] - Building GIMP on Linux
 +
* [[Hacking: Building/Mac OSX]] - Building GIMP on the Mac platform
 +
* [[Hacking:Building/Windows]] - Building GIMP on Windows
 +
 
 +
1. Choose a place to install everything, and set a variable to point to it:
 +
 
 +
<pre>
 +
export INSTALL_PREFIX=$HOME/gimp-git
 +
</pre>
 +
 
 +
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:
 +
 
 +
<pre>
 +
mkdir -p $INSTALL_PREFIX/share
 +
</pre>
 +
 
 +
Create a file named $INSTALL_PREFIX/share/config.site containing this:
 +
<pre>
 +
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"
 +
</pre>
 +
 
 +
== Check Out the Source ==
 +
 
 +
Clone from git:
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
Or get tarballs from:
 +
<pre>
 +
http://download.gimp.org/pub/babl/
 +
http://download.gimp.org/pub/gegl/
 +
http://download.gimp.org/pub/gimp/
 +
</pre>
 +
 
 +
=== Additional Git Requirements ===
 +
 
 +
To Build Git Master, You Also Need:
 +
<pre>
 +
git clone https://github.com/mypaint/mypaint-brushes.git
 +
git clone https://github.com/mypaint/libmypaint.git
 +
</pre>
 +
 
 +
== Build babl ==
 +
 
 +
<pre>
 +
cd babl
 +
SRCDIR=$(pwd)
 +
BUILD_DIR=$SRCDIR/obj-$(arch)
 +
mkdir -p $BUILD_DIR
 +
cd $BUILD_DIR
 +
meson -Dprefix=$INSTALL_PREFIX $SRCDIR && ninja && ninja install
 +
</pre>
 +
 
 +
== 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:
 +
 
 +
<pre>
 +
./autogen.sh
 +
</pre>
 +
 
 +
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:
 +
<pre>
 +
./configure --prefix=INSTALL_PREFIX
 +
</pre>
 +
 
 +
Check the output to make sure you aren't missing any features you might want.
 +
Then:
 +
 
 +
<pre>
 +
make && make install
 +
</pre>
 +
 
 +
Then repeat for mypaint-brushes.
 +
 
 +
== Build gegl and gimp ==
 +
 
 +
The steps for gegl and gimp are very similar, but slightly easier because
 +
./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:
 +
 
 +
<pre>
 +
./autogen.sh --prefix=INSTALL_PREFIX
 +
</pre>
 +
 
 +
This generates a configure script.
 +
 
 +
If you're building from a tarball, use configure instead of autogen:
 +
<pre>
 +
./configure --prefix=INSTALL_PREFIX
 +
</pre>
 +
 
 +
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:
 +
 
 +
<pre>
 +
make && make install
 +
</pre>
  
=== The build process ===
+
Repeat the same steps for gimp.
GIMP, together with GEGL and babl, all use the Gnu build system. This means that compiling them basically consists of 4 steps:
+
# autogen.sh script - This script generates the ./configure script for the next step<pre>./autogen.sh</pre>In many cases, the autogen script also runs the configure script (see the next step) so we can usually pass arguments to it that will be passed to the configure script. '''This step is only needed when building from Git (and not from a Tarball)!'''
+
# configure script - This script does many checks to check which compilers and libraries you have available, which features are enabled and not, etc. When it finishes, it generates the Makefile's which are used by the make tool.<pre>./configure</pre>Usually you can see all the options that you can specify to the script, by running<pre>./configure --help</pre>One option that we'll use through all of the building tutorials, is the --prefix option<pre>./configure --prefix=/PATH/TO/INSTALL/FOLDER</pre>The path given there is used to specify where do we want the compiled result to be installed to. This is useful when you want to install to places other than the default, for example when we are doing beta-builds and we don't want them to conflict with our existing installation. This can also be used on Linux/Unix system to install into the home-directory, in cases one does not have root access.<br />'''If you are doing anything other than simply building <u>from a tarball</u>, do not run the configure script directly! Instead, run the autogen script and let it call the configure script for you!''' This is because there are some changes in the code (either locally, or in Git between tarball releases) that will not be handled correctly without the autogen script! (Thanks to schumaml from the GIMP IRC for pointing that out)
+
# make - The make tool uses files called Makefile, which are present at each directory, in order to call the compilers and other tools and use them on the apropriate source files<pre>make</pre>We can speed up the process by running several jobs at once (this is useful when we have a processor with several cores). For example, if we want to run 4 jobs at once, we'll do<pre>make -j4</pre>
+
# Now, we finally install the compiled result by invoking the make tool again, with the "install" target<pre>make install</pre>
+
  
== Additional notes ==
+
== Running Your New GIMP ==
=== GIMP ===
+
* To compile GIMP you need Perl and intltool
+
* To compile GIMP's Python support, you need PyGTK (a Python package)
+
* Linking static versions of the most libraries (i.e. libgevix2) is not supported by GIMP. Use their dynamic versions.
+
  
=== GEGL ===
+
You will probably need to set some environment variables in order to run the gimp you just built.
* To compile GEGL from Git, you need Ruby (a language interpreter)
+
See the pages for specific OSes for advice:
  
== Specific Builds ==
 
 
* [[Hacking:Building/Linux]] - Building GIMP on Linux
 
* [[Hacking:Building/Linux]] - Building GIMP on Linux
 
* [[Hacking: Building/Mac OSX]] - Building GIMP on the Mac platform
 
* [[Hacking: Building/Mac OSX]] - Building GIMP on the Mac platform
 
* [[Hacking:Building/Windows]] - Building GIMP on Windows
 
* [[Hacking:Building/Windows]] - Building GIMP on Windows

Revision as of 21:21, 10 August 2019

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

GIMP's dependencies

Gimp depends on the following common libraries for its core:

  • 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.
  • 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 build tools to build GIMP, including a C compiler, make, GNU autotools, meson and more. 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

Create a file named $INSTALL_PREFIX/share/config.site containing this:

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"

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 babl

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

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 gegl and gimp

The steps for gegl and gimp are very similar, but slightly easier because ./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.

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.

Running Your New GIMP

You will probably need to set some environment variables in order to run the gimp you just built. See the pages for specific OSes for advice: