Difference between revisions of "Hacking:Building/Linux"

From GIMP Developer Wiki
Jump to: navigation, search
(Running our compiled version of GIMP)
(Ubuntu 19.10)
 
(19 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This guide will explain you how to install GIMP, even without root/admin permissions/privileges. It will explain how to install GIMP to a custom location so that it won’t conflict with your existing GIMP installation. Through this guide, I’m going to use the bash shell for executing stuff from the command line – it’s usually located in /bin/bash.
+
The main GIMP building instructions are at [[Hacking:Building]].
  
'''Perquisites:'''
+
This page is for Linux-specific additions to that page.
* You should know roughly what is a command-line/terminal/shell. You should also know how to open the command-line/terminal/shell.
+
* You should know roughly what are environment variables.
+
* You should read and understand [[Hacking:Building]]
+
''Note:'' This page is heavily based on [http://lightningismyname.blogspot.com/p/compiling-gimp.html this guide]
+
 
+
'''DO NOT BUILD GIMP OR ITS DEPENDENCIES IN PREFIX /usr/local'''
+
 
+
Just don't. Start a new prefix either in /opt or /home/yourusername/blah. If you do and you run into problems, feel free to clean up and start over elsewhere.
+
As a general rule, it is better to never use the root user except you know what you are doing. For this reason, we will assume you will set the prefix in a directory with write rights for your user (for instance under their $HOME directory). In particular it means that the `make install` steps will never need any root rights (i.e. no `sudo` needed).
+
 
+
If you know what you are doing and want to install in a directory with administrative rights, then… well you know what you are doing.
+
 
+
== The Basics - Environment Variables ==
+
The main "problem" (don't worry, it's solvable) with compiling gimp on Linux, is environment variables. There are 3 environment variables which we should get to know when compiling things on Linux, and we’ll now present them:
+
 
+
=== PATH ===
+
First of all, this environment variable specifies where to look for executables. When you type "gimp" in the command line, all the directories inside the path will be searched.
+
<pre>lightning@nova:~$ echo $PATH
+
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/local32/bin:.</pre>
+
As you can see, the path is composed out of a list of paths to directories, separated by ':' signs. The order of directories inside the path does matter! Directories which are listed first, are searched first!
+
 
+
=== PKG_CONFIG_PATH ===
+
This environment variable tells the pkg-config tool (a tool which is used to resolve most dependencies in GIMP’s compilation) where to look for the config files (which are used by pkg-config) for installed libraries.
+
 
+
=== LD_LIBRARY_PATH ===
+
Many executables used files which are called shared libraries – these files contain functionality that should be shared between executables. One example which you should know (if you are a Linux user) is Gtk+ – the library which is used by many applications (including GIMP) to create the user interface.
+
 
+
The executables search for these libraries inside some directories which are considered as “default”. So, in order for us to install and use libraries in other locations we need to update this variable to point to the directory leading to these libraries.
+
 
+
=== CFLAGS, CPPFLAGS, LIBS ===
+
These variables are used to specify additional arguments to the C compiler (CFLAGS), the C Pre-Processor (CPPFLAGS) and the linker (LIBS). Since we install things in paths other than the default, we will possibly need to use them to specify the tools where to look for our installed stuff.
+
 
+
=== What’s the problem with environment variables? ===
+
We don’t want to compile GIMP and install it in the default location, because then it may conflict with our existing installation. But if we install GIMP at a different location, we need to configure the environment variables so that the correct versions of libraries will be found and used, both for compilation and for running GIMP.
+
 
+
== Preparing for compilation ==
+
First of all, we need to decide where do we want to install the alternative version of GIMP. To make it easy to remember and use, we’ll define an environment variable containing that path:
+
<pre>export INSTALL_PREFIX=$HOME/dev/gimp-prefix/</pre>
+
We will also need a directory to download the sources to; this is the directory I used. Change it to your own:
+
<pre>export SRC_DIR=/vol/scratch/gimp-beta/src</pre>
+
You’ll need to make sure both of these directories actually exist, and if not, create them. You can do it by running following commands:
+
<pre>mkdir -p $INSTALL_PREFIX
+
mkdir -p $SRC_DIR</pre>
+
Now, remember the discussion we had about environment variables? Here are the updates we need to do:
+
<pre>export PATH=$INSTALL_PREFIX/bin:$PATH
+
export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
+
export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib:$LD_LIBRARY_PATH</pre>
+
In the first line, we update the PATH variable, so that looking for executables will begin in our installation directory (executables will be installed into the bin subdirectory).
+
In the second line, we tell pkg-config that it should begin searching for library config files in our installation directory. '''This will resolve many compilation issues!''' For example, this will allow us to compile plug-ins against our updated version of the GIMP libraries, even if we have the old ones installed.
+
In the third line, we tell the library loader that it should first of all try to look for libraries in our installation directory – this will prevent it from loading the libraries of other GIMP versions (that can cause trouble...).
+
  
 
== Dependencies ==
 
== Dependencies ==
Since you already read about GIMP's dependencies in [[Hacking:Building]], you should already know roughly what does GIMP rely on. Any recent linux distribution should have most dependencies listed in the previous page, except for babl and GEGL. If you'll encounter errors in the process, about missing dependencies or too old versions of dependencies, see the troubleshooting section at the bottom of this page.
 
 
'''NOTE''': some distribution have more up-to-date versions of libraries, and therefore are more adapted for developers. For instance: Debian Testing, Fedora… In particular using some user-oriented distributions (for instance Ubuntu), you will have more dependencies to build yourself, and in worst cases, you may encounter dependency conflicts.
 
 
== Compiling libmypaint-gegl from source ==
 
This step is only needed if you're building GIMP git master. This library isn't available on most Linux distros, so you'll have to build it from source.
 
 
Note: the libmypaint master branch is currently subject to change, so GIMP requires v1.3.0. The commands below use git checkout to get the corresponding tag from the libmypaint repository.
 
 
<pre>
 
git clone https://github.com/mypaint/libmypaint.git
 
cd libmypaint/
 
git checkout v1.3.0
 
sudo apt-get install libjson-c-dev
 
./autogen.sh && ./configure --prefix=$INSTALL_PREFIX && make && make install
 
</pre>
 
 
== Compiling babl, GEGL and GIMP from source ==
 
The procedure for compiling babl, GEGL and GIMP is very easy once you have the dependencies. Note that the order here matters – we first need to have babl, then GEGL and finally GIMP.
 
=== Getting the sources ===
 
You can download the source tarballs of all 3 from the [http://download.gimp.org/pub/ GIMP.org]:
 
<pre>http://download.gimp.org/pub/babl/
 
http://download.gimp.org/pub/gegl/
 
http://download.gimp.org/pub/gimp/</pre>
 
Or you can download the sources from Git (you'll need to have git installed):
 
<pre>git clone git@gitlab.gnome.org:GNOME/babl.git
 
git clone git@gitlab.gnome.org:GNOME/gegl.git
 
git clone git@gitlab.gnome.org:GNOME/gimp.git</pre>
 
 
If you are behind a corporate firewall, you can also try Git over HTTPS:
 
<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>
 
If you downloaded the source tarballs (the filename will end with .tar.gz or .tar.bz2), you'll need to extract them by executing
 
<pre>tar -xf FILE -C DIR</pre>
 
Where FILE should be the path to the file you want to extract and DIR is the directory into which you wish to extract the sources.
 
 
=== Actual Building ===
 
For each one of babl, GEGL and GIMP (in this order!) do:
 
# Enter the source directory<pre>cd PATH/TO/DIRECTORY</pre>Replace with apropriate path
 
# If you downloaded a source Tarball, run the configure script with our desired install prefix<pre>./configure --prefix=$INSTALL_PREFIX</pre> Ohterwise, if you downloaded the source from git, run the autogen script with same argument<pre>./autogen.sh --prefix=$INSTALL_PREFIX</pre>If you encounter errors about missing dependancies, look at these suggestions:
 
#* When running it for GIMP, if you don't have Python and PyGtk, you'll need to disable them explicitly by appending the following argument to the command above<pre>--disable-python</pre>
 
#* When running it for GIMP, if you don't have gtk-doc, you'll need to disable it explicitly by appending the following argument to the command above<pre>--disable-gtk-doc</pre>
 
#* When running it for GIMP, if you got some error message about some missing libraries, and they weren't listed as the core dependancies of GIMP in [[Hacking:Building]], you can try to disable them. You can list the options that the configure script accepts by running <pre>./configure --help</pre>You can do the same with the autogen script (since it passes it's flags to the configure script!)<br />Now, look for some option which is called --disable-XXX or --without-XXX, where XXX is the thing which causes your problem. If you found such an option, simply append it to the list of arguments (without the --help) and try again.
 
# Run make <pre>make</pre>
 
# Run make install <pre>make install</pre>
 
 
== Running our compiled version of GIMP ==
 
Now, we should be careful before running GIMP. Our compilation was done with some very specific environment variables, and running GIMP will depend on them! So, let’s save our environment variables into a script that runs GIMP:
 
<pre>echo "#! /bin/bash
 
 
# set the path to the installation directory
 
export INSTALL_PREFIX=$INSTALL_PREFIX
 
 
# set the path to the directory into which we download the sources
 
export SRC_DIR=$SRC_DIR
 
 
# Now, set mandatory enviroment variables
 
export PATH=\$INSTALL_PREFIX/bin:\$PATH
 
export LD_LIBRARY_PATH=\$INSTALL_PREFIX/lib:\$LD_LIBRARY_PATH
 
 
# Not needed for running GIMP directly, but needed if you want to compile anything against our
 
# builds (think of plug-ins, etc.)
 
export PKG_CONFIG_PATH=\$INSTALL_PREFIX/lib/pkgconfig:\$PKG_CONFIG_PATH
 
 
# Now you can run executables our other stuff depending on our environment
 
# Here we run GIMP, and pass it any arguments given to this script
 
\$INSTALL_PREFIX/bin/gimp-2.10 \$@
 
 
# If you want to run something else, copy paste into bash everything before the line that
 
# runs GIMP, and then run it
 
" &gt; $INSTALL_PREFIX/run-gimp.sh
 
 
chmod +x $INSTALL_PREFIX/run-gimp.sh</pre>
 
This command creates a script file called run-gimp.sh (inside our installation directory), which sets our environment variables, and then runs GIMP. The script will also contain instructions about running things other than GIMP using our environment. If you finished this step without errors, you should now have a working build of GIMP!
 
''Note:'' If you compiled a gimp version other than 2.10, replace the 2.10 with the correct version.
 
 
== Troubleshooting ==
 
* I’m getting an error about a too low of GTK+/GLib while compiling XXX
 
*: You can either update your version of GTK+/GLib using your system’s package manager, or compile GTK+/GLib from source! Compiling these is done exactly like we compiled babl – download the source (either the latest from Git, or a package from the official site), compile and install. You may also need to do something like this to a library called ATK.
 
* I’m getting some error about relative path in the prefix
 
*: The installation directory of libraries/executables must be specified in an absolute path and not in a relative path. If you got this error, it means that one of the paths in your environment variables is relative and not absolute – fix that!
 
* I'm getting errors about missing/old version of Gtk+/Glib/etc.
 
*: The 3/4 step process described in [[Hacking:Building]] for building should work for building most if not all of GIMP's dependancies. Like we compiled GIMP, you should download the sources, run configure then make and finally make install. Use Google or some other search engine to find the website of the package and download it's source from it. Of course that if possible, you should try to install these dependencies through your system's package manager (if you have root permissions) and by that you'll save the time and effort of the compilation.
 
 
 
== Building the Documentation ==
 
 
 
 
To build the documentation
 
 
git clone --depth=0 git@gitlab.gnome.org:GNOME/gimp-help.git
 
cd gimp-help
 
./autogen.sh [--without-gimp ALL_LINGUAS="en"]
 
LINGUAS=en make
 
LINGUAS=en make pdf-local
 
 
Substitute your language options in the above.
 
 
'''Notes'''<br />
 
The production of the documentation requires '''''docbook''''' and ancillary programs. Here are some of the other programs;<br />
 
'''''gettext'''''<br />
 
'''''automake'''''<br />
 
'''''docbook2odf'''''<br />
 
'''''pngcrush'''''<br />
 
'''''pngnq'''''<br />
 
'''''docbook-xsl '''''<br />
 
'''''docbook-utils'''''<br />
 
'''''dblatex'''''<br />
 
Which may or may not already installed. Running autogen will stop at the failed dependency, so install and repeat the process till autogen finishes.
 
 
  
 +
GIMP relies on a lot of other packages in addition to <code>babl</code>, <code>gegl</code>, <code>libmypaint</code> and <code>mypaint-brushes</code>.
  
It is recommended that you read the '''README'''.
+
The requirements change frequently, but this page contains dependencies lists for different linux distributions.
  
----
+
==== Ubuntu 19.10 ====
 +
Workin in October 2019.
 +
sudo apt install \
 +
    libtool intltool \
 +
    meson \
 +
    asciidoc \
 +
    exiv2 libgexiv2-dev \
 +
    gjs \
 +
    gtk-3-examples \
 +
    gtk-doc-tools \
 +
    jasper \
 +
    libaa1-dev \
 +
    libappstream-glib-dev \
 +
    libarchive-dev \
 +
    libavcodec-dev libavformat-dev libavutil-dev \
 +
    libbz2-dev \
 +
    libgs-dev \
 +
    libgtk-3-dev libgtk2.0-dev gobject-introspection \
 +
    libgirepository1.0-dev \
 +
    libgudev-1.0-dev \
 +
    libheif-dev \
 +
    libjson-c-dev libjson-glib-dev \
 +
    liblcms2-dev \
 +
    liblensfun-dev \
 +
    libmng-dev \
 +
    libopenexr-dev \
 +
    libjpeg-dev libopenjp2-7-dev \
 +
    libpoppler-glib-dev \
 +
    libraw-dev \
 +
    librsvg2-bin librsvg2-dev \
 +
    libsdl2-dev \
 +
    libspiro-dev \
 +
    libswscale-dev \
 +
    libtiff-dev \
 +
    libumfpack5 \
 +
    libv4l-dev \
 +
    libwebkit2gtk-4.0-dev \
 +
    libwebp-dev \
 +
    luajit \
 +
    python-gi-dev python3-venv python3-wheel \
 +
    ruby \
 +
    w3m \
 +
    xsltproc

Latest revision as of 23:27, 21 November 2019

The main GIMP building instructions are at Hacking:Building.

This page is for Linux-specific additions to that page.

Dependencies

GIMP relies on a lot of other packages in addition to babl, gegl, libmypaint and mypaint-brushes.

The requirements change frequently, but this page contains dependencies lists for different linux distributions.

Ubuntu 19.10

Workin in October 2019.

sudo apt install \
    libtool intltool \
    meson \
    asciidoc \
    exiv2 libgexiv2-dev \
    gjs \
    gtk-3-examples \
    gtk-doc-tools \
    jasper \
    libaa1-dev \
    libappstream-glib-dev \
    libarchive-dev \
    libavcodec-dev libavformat-dev libavutil-dev \
    libbz2-dev \
    libgs-dev \
    libgtk-3-dev libgtk2.0-dev gobject-introspection \
    libgirepository1.0-dev \
    libgudev-1.0-dev \
    libheif-dev \
    libjson-c-dev libjson-glib-dev \
    liblcms2-dev \
    liblensfun-dev \
    libmng-dev \
    libopenexr-dev \
    libjpeg-dev libopenjp2-7-dev \
    libpoppler-glib-dev \
    libraw-dev \
    librsvg2-bin librsvg2-dev \
    libsdl2-dev \
    libspiro-dev \
    libswscale-dev \
    libtiff-dev \
    libumfpack5 \
    libv4l-dev \
    libwebkit2gtk-4.0-dev \
    libwebp-dev \
    luajit \
    python-gi-dev python3-venv python3-wheel \
    ruby \
    w3m \
    xsltproc