Difference between revisions of "Hacking:Building/Linux"

From GIMP Developer Wiki
Jump to: navigation, search
(Add some more packages needed to build.)
(Ubuntu 19.10)
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
The main GIMP building instructions are at [[Hacking:Building]].
 
The main GIMP building instructions are at [[Hacking:Building]].
 +
 
This page is for Linux-specific additions to that page.
 
This page is for Linux-specific additions to that page.
 
__TOC__
 
 
== Prerequisites: ==
 
* 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]]
 
 
== DO NOT BUILD GIMP OR ITS DEPENDENCIES IN PREFIX /usr/local ==
 
 
Just don't. Create a new directory (called a "build prefix") somewhere like /opt or /home/yourusername/blah. Or you can use a directory under /usr/local, for example, /usr/local/mygimp.
 
 
Installing a self-built gimp into system directories can lead to cases where you're using some libraries from your new gimp, and some libraries from an older version; things will fail in unexpected ways and it's hard to figure out what's wrong.
 
 
Using a special install prefix has another benefit: you can use something that's writable by you, so you don't need to use sudo or root at any time during the build. That reduces the risk of doing something wrong accidentally.
 
 
If you know what you are doing and want to install in a directory with administrative rights, it's your call. You've been warned.
 
  
 
== Dependencies ==
 
== Dependencies ==
  
GIMP depends on a lot of other packages in addition to babl, gegl, libmypaint and mypaint-brushes. The requirements change frequently, but on a freshly installed Ubuntu 19.10 system in October 2019, this was enough for most of GIMP's dependencies (there are still a few missing formats, but it builds):
+
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>.
 
+
<pre wrap>
+
sudo apt install libtool intltool libjson-c-dev meson python3-venv \
+
    python3-wheel cmake liblcms2-dev librsvg2-bin w3m libgtk2.0-dev \
+
    gobject-introspection libjson-glib-dev libgirepository1.0-dev asciidoc \
+
    ruby exiv2 libgexiv2-dev jasper liblensfun-dev libjpeg-dev \
+
    libraw-dev librsvg2-dev libspiro-dev libtiff-dev libv4l-dev luajit \
+
    libopenexr-dev libsdl2-dev libwebp-dev python-gi-dev libavcodec-dev \
+
    libavformat-dev libavutil-dev libswscale-dev libumfpack5 libgtk-3-dev \
+
    libbz2-dev libappstream-glib-dev libarchive-dev gtk-3-examples gjs \
+
    libpoppler-glib-dev xsltproc gtk-doc-tools libaa1-dev libwebkit2gtk-4.0-dev \
+
    libgudev-1.0-dev libmng-dev libheif-dev
+
</pre>
+
 
+
== Environment Variables ==
+
There are three environment variables that are important when building and running programs on Linux:
+
 
+
=== PATH ===
+
Your path specifies where to look for executables. When you type "gimp" in the command line, all the directories inside the path will be searched.
+
<pre>$ echo $PATH
+
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:.</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! If you have versions of gimp in two different directories in your path, when you type "gimp" you'll get whichever one came first.
+
 
+
=== PKG_CONFIG_PATH ===
+
pkg-config is a tool used during builds to determine what version of each library should be used for the build. If your PKG_CONFIG_PATH doesn't point to the right directories inside your install prefix, the build system probably won't realize that you have the right version of gegl, or mypaint, or whatever, and will tell you it needs a newer version.
+
 
+
=== LD_LIBRARY_PATH ===
+
This is used when running a program, to tell it where to find shared libraries used by that program. When you run your newly built gimp, you'll need LD_LIBRARY_PATH to point to the "lib" directory inside your install prefix, or it won't find the libraries you built.
+
 
+
You can set these variables in the shell environment where you build gimp (be sure to use "export"), but an easier way is to create a config.site file in your install prefix's share directory, as described in [[Hacking:Building]].
+
 
+
=== Don't use config.site ===
+
 
+
If you've built GIMP in the past, you may be familiar with a file called config.site that you put inside the prefix. That no longer works with meson builds; you'll have to set these environment variables in your shell before you build. If you already have a site, you can probably run: <pre>source $PREFIX/share/config.site</pre>. Otherwise, see the next section.
+
 
+
== Setting environment variables ==
+
 
+
The exact value of each of these environment variables depends on which Linux distro you're running and how it's configured.
+
 
+
Here are a few examples that have worked for some of the GIMP developers. The locations of $PREFIX are just examples; it can be anywhere.
+
 
+
XDG_DATA_DIRS is for running GIMP (you may or may not need it), but for building, on some machines it will break the build. Some other environment variables may also cause strange behaviors on some system if not set correctly. See [[Hacking:Problems_and_solutions]] if you have any problems beyond just missing packages.
+
 
+
=== Debian Testing ===
+
 
+
<pre>
+
export PREFIX=$HOME/run/gimp-git
+
export PATH="$PREFIX/bin:$PATH"
+
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
+
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
+
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal $ACLOCAL_FLAGS"
+
 
+
# XDG_DATA_DIRS should not be set for building, but you may need it for running:
+
# export XDG_DATA_DIRS=$PREFIX/share:$XDG_DATA_DIRS
+
</pre>
+
 
+
=== Debian Sid with 64-bit libs specified explicitly ===
+
 
+
Some developers find that babl and gegl install themselves to 64-bit libraries, and need to set their environment accordingly:
+
 
+
<pre>
+
PREFIX=$HOME/code-install/gimp210/install
+
export PATH=$PREFIX/bin:$PATH
+
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal"
+
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
+
export LD_LIBRARY_PATH=$PREFIX/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
+
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
+
export PKG_CONFIG_PATH=$PREFIX/lib/x86_64-linux-gnu:$PKG_CONFIG_PATH
+
export PKG_CONFIG_PATH=$PREFIX/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
+
export PKG_CONFIG_PATH=$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH
+
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$PREFIX/share:/usr/local/share/:/usr/share/"
+
</pre>
+
 
+
=== Gentoo ===
+
 
+
<pre>
+
PREFIX=$HOME/code-install/gimp210/install
+
export SRC_DIR=/hdd/data1/code-build/gimp210/build
+
export PATH=$PREFIX/bin:$PATH
+
export ACLOCAL_FLAGS="-I $PREFIX/share/aclocal"
+
export LD_LIBRARY_PATH=$PREFIX/lib:$LD_LIBRARY_PATH
+
export LD_LIBRARY_PATH=$PREFIX/lib64:$LD_LIBRARY_PATH
+
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH
+
export PKG_CONFIG_PATH=$PREFIX/lib64/pkgconfig:$PKG_CONFIG_PATH
+
export PKG_CONFIG_PATH=$PREFIX/install/share/pkgconfig:$PKG_CONFIG_PATH
+
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$PREFIX/share"
+
</pre>
+
 
+
 
+
== Running Your Compiled Version of GIMP ==
+
You've been through [[Hacking:Building]] and finished your build successfully. How do you run it, given that all the programs and libraries are in your special build prefix?
+
 
+
The easiest way is to use a script like this one:
+
 
+
<pre>
+
#! /bin/sh
+
 
+
# set the path to the installation directory if it isn't already set
+
# in your environment.
+
# export GIMP_PREFIX=/path/to/your/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=$GIMP_PREFIX/bin:$PATH
+
export LD_LIBRARY_PATH=$GIMP_PREFIX/lib:$LD_LIBRARY_PATH
+
 
+
echo LD_LIBRARY_PATH is $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=$GIMP_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
+
$GIMP_PREFIX/bin/gimp-2.10 $@
+
</pre>
+
 
+
This command creates a shell script that sets some required environment variables and then runs 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.
+
 
+
 
+
For other problems, see: [[Hacking:Problems and solutions]]
+
 
+
== Building the Documentation ==
+
 
+
To build the documentation
+
 
+
<pre>
+
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
+
</pre>
+
 
+
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.
+
  
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

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