Difference between revisions of "Hacking:Building/Windows"

From GIMP Developer Wiki
Jump to: navigation, search
(To Do)
Line 1: Line 1:
The main GIMP building instructions are at [[Hacking:Building]]. This page is for Windows-specific additions to that page.  
+
A developer can build and develop GIMP using Windows. One reason to do so is to fix any GIMP bugs specific to the Windows platform.  However, there is already a package of GIMP for Windows (at: [http://gimp-win.sourceforge.net/ GIMP Windows installers by Jernej Simončič.]). A GIMP debugger or developer would still need to submit patches to the GIMP development team.
  
Note: the instructions are not always kept up to date. The primary development platform is the Debian Testing GNU/Linux distribution, so the very latest code from Git might not always build on other platforms.
+
Note: the instructions are not always kept up to date; check on irc.gnome.org #gimp first if you are not sure. The primary development platform is the Debian Testing GNU/Linux distribution, so the very latest code from GIT might not always build on other platforms.
  
 
== Building GIMP natively under Windows using MSYS2 ==
 
== Building GIMP natively under Windows using MSYS2 ==
  
Msys2 is a POSIX environment with basically everything you would find on a Linux system (shell, package manager, GCC…). It allows to use POSIX tools to build Windows softwares.
+
As 6/1/2019 you can build only the Gimp 2.10 branch due missing dependences on master branch
  
=== Setting up the environment ===
+
=== Setting up a devel environment ===
  
First, '''follow the installation instructions''' for msys2 available at [https://msys2.github.io msys2.github.io].
+
First, '''follow the installation instructions''' for msys2 available at [https://msys2.github.io/ msys2.github.io].
  
To open a terminal, you need to execute <code>msys2.exe</code> or <code>mingw64.exe</code>
+
Make sure to follow the post-installation instructions on that page to update the msys2, mingw64, mingw32 systems appropriately.
 +
This includes:
  
Update the system :
+
* Updating pacman and the package database:
  pacman -Syyuu
+
<nowiki>pacman -Sy pacman</nowiki>
 +
* If needed, close MSYS2 and run it again (note: the installed .bat files don't appear to work on win10, launch it directly from the install location, ie: c:\msys2\msys2.exe).<br/>Update the package database and core system packages:
 +
  <nowiki>pacman -Syu</nowiki>
  
If the shell tells you to close the terminal, close MSYS2 and run it again. That is a normal procedure.
+
''If an error is thrown'' about <code>incompatible versions of the cygwin DLL</code> and the following warnings are shown:
  
=== Install the dependencies ===
+
warning: terminate MSYS2 without returning to shell and check for updates again
 +
warning: for example close your terminal window instead of calling exit
  
==== If you want to build gimp 2.10 ====
+
Then follow the instructions and close the terminal window (it may warn you of running processes, choose "OK" to close it anyway).
  
If you have Windows 64bits:
+
Re-open MSYS2 from the install directory by running <code>msys2_shell.cmd</code>, and re-run the update command <code>pacman -Syu</code>.
pacman -S \
+
    base-devel \
+
    git \
+
    mingw-w64-x86_64-toolchain \
+
    mingw-w64-x86_64-asciidoc \
+
    mingw-w64-x86_64-drmingw \
+
    mingw-w64-x86_64-gexiv2 \
+
    mingw-w64-x86_64-ghostscript \
+
    mingw-w64-x86_64-glib-networking \
+
    mingw-w64-x86_64-graphviz \
+
    mingw-w64-x86_64-gtk2 \
+
    mingw-w64-x86_64-iso-codes \
+
    mingw-w64-x86_64-json-c \
+
    mingw-w64-x86_64-json-glib \
+
    mingw-w64-x86_64-lcms2 \
+
    mingw-w64-x86_64-lensfun \
+
    mingw-w64-x86_64-libheif \
+
    mingw-w64-x86_64-libraw \
+
    mingw-w64-x86_64-libspiro \
+
    mingw-w64-x86_64-libwebp \
+
    mingw-w64-x86_64-libwmf \
+
    mingw-w64-x86_64-meson \
+
    mingw-w64-x86_64-openexr \
+
    mingw-w64-x86_64-poppler \
+
    mingw-w64-x86_64-python2-pygtk \
+
    mingw-w64-x86_64-SDL2 \
+
    mingw-w64-x86_64-suitesparse \
+
    mingw-w64-x86_64-vala \
+
    mingw-w64-x86_64-xpm-nox
+
  
If you have Windows 32 bit:
+
* If needed, close MSYS2 and run it again (again).<br/>Finally update the rest with one more call:
  pacman -S \
+
  <nowiki>pacman -Su</nowiki>
    base-devel \
+
    git \
+
    mingw-w64-i686-toolchain \
+
    mingw-w64-i686-asciidoc \
+
    mingw-w64-i686-drmingw \
+
    mingw-w64-i686-gexiv2 \
+
    mingw-w64-i686-ghostscript \
+
    mingw-w64-i686-glib-networking \
+
    mingw-w64-i686-graphviz \
+
    mingw-w64-i686-gtk2 \
+
    mingw-w64-i686-iso-codes \
+
    mingw-w64-i686-json-c \
+
    mingw-w64-i686-json-glib \
+
    mingw-w64-i686-lcms2 \
+
    mingw-w64-i686-lensfun \
+
    mingw-w64-i686-libheif \
+
    mingw-w64-i686-libraw \
+
    mingw-w64-i686-libspiro \
+
    mingw-w64-i686-libwebp \
+
    mingw-w64-i686-libwmf \
+
    mingw-w64-i686-meson \
+
    mingw-w64-i686-openexr \
+
    mingw-w64-i686-poppler \
+
    mingw-w64-i686-python2-pygtk \
+
    mingw-w64-i686-SDL2 \
+
    mingw-w64-i686-suitesparse \
+
    mingw-w64-i686-vala \
+
    mingw-w64-i686-xpm-nox
+
  
 +
Once everything is updated, exit out of MSYS2.
  
==== If you want to build gimp master ====
+
The shortcut for running mingw64, called "MinGW-w64 Win64 Shell" won't work after the update.
  
If you have Windows 64bits:
+
Run <code>mingw64.exe</code> directly from the install directory (by default: <code>c:\msys64\mingw64.exe</code> or <code>c:\msys32\mingw32.exe</code>).
pacman -S \
+
    base-devel \
+
    git \
+
    mingw-w64-x86_64-toolchain \
+
    mingw-w64-x86_64-appstream-glib \
+
    mingw-w64-x86_64-asciidoc \
+
    mingw-w64-x86_64-drmingw \
+
    mingw-w64-x86_64-gexiv2 \
+
    mingw-w64-x86_64-ghostscript \
+
    mingw-w64-x86_64-glib-networking \
+
    mingw-w64-x86_64-graphviz \
+
    mingw-w64-x86_64-gtk3 \
+
    mingw-w64-x86_64-gobject-introspection \
+
    mingw-w64-x86_64-iso-codes \
+
    mingw-w64-x86_64-json-c \
+
    mingw-w64-x86_64-json-glib \
+
    mingw-w64-x86_64-lcms2 \
+
    mingw-w64-x86_64-lensfun \
+
    mingw-w64-x86_64-libarchive \
+
    mingw-w64-x86_64-libheif \
+
    mingw-w64-x86_64-libraw \
+
    mingw-w64-x86_64-libspiro \
+
    mingw-w64-x86_64-libwebp \
+
    mingw-w64-x86_64-libwmf \
+
    mingw-w64-x86_64-luajit \
+
    mingw-w64-x86_64-meson \
+
    mingw-w64-x86_64-openexr \
+
    mingw-w64-x86_64-poppler \
+
    mingw-w64-x86_64-python3-gobject \
+
    mingw-w64-x86_64-SDL2 \
+
    mingw-w64-x86_64-suitesparse \
+
    mingw-w64-x86_64-vala \
+
    mingw-w64-x86_64-xpm-nox
+
  
If you have Windows 32bits:
+
'''If you want to build gimp 2.10'''
  pacman -S \
+
 
    base-devel \
+
<nowiki>
    git \
+
If you have Windows 64 bit in this shell run:
    mingw-w64-i686-toolchain \
+
 
    mingw-w64-i686-appstream-glib \
+
pacman -S base-devel \
    mingw-w64-i686-asciidoc \
+
mingw-w64-x86_64-toolchain \
    mingw-w64-i686-drmingw \
+
git \
    mingw-w64-i686-gexiv2 \
+
mingw-w64-x86_64-asciidoc \
    mingw-w64-i686-ghostscript \
+
mingw-w64-x86_64-drmingw \
    mingw-w64-i686-glib-networking \
+
mingw-w64-x86_64-gexiv2 \
    mingw-w64-i686-graphviz \
+
mingw-w64-x86_64-ghostscript \
    mingw-w64-i686-gtk3 \
+
mingw-w64-x86_64-glib-networking \
    mingw-w64-i686-gobject-introspection \
+
mingw-w64-x86_64-gobject-introspection \
    mingw-w64-i686-iso-codes \
+
mingw-w64-x86_64-graphviz \
    mingw-w64-i686-json-c \
+
mingw-w64-x86_64-gtk2 \
    mingw-w64-i686-json-glib \
+
mingw-w64-x86_64-iso-codes \
    mingw-w64-i686-lcms2 \
+
mingw-w64-x86_64-json-c \
    mingw-w64-i686-lensfun \
+
mingw-w64-x86_64-json-glib \
    mingw-w64-i686-libarchive \
+
mingw-w64-x86_64-lcms2 \
    mingw-w64-i686-libheif \
+
mingw-w64-x86_64-lensfun \
    mingw-w64-i686-libraw \
+
mingw-w64-x86_64-libheif \
    mingw-w64-i686-libspiro \
+
mingw-w64-x86_64-libraw \
    mingw-w64-i686-libwebp \
+
mingw-w64-x86_64-libspiro \
    mingw-w64-i686-libwmf \
+
mingw-w64-x86_64-libwebp \
    mingw-w64-i686-luajit \
+
mingw-w64-x86_64-libwmf \
    mingw-w64-i686-meson \
+
mingw-w64-x86_64-meson \
    mingw-w64-i686-openexr \
+
mingw-w64-x86_64-openexr \
    mingw-w64-i686-poppler \
+
mingw-w64-x86_64-poppler \
    mingw-w64-i686-python3-gobject \
+
mingw-w64-x86_64-python2-pygtk \
    mingw-w64-i686-SDL2 \
+
mingw-w64-x86_64-SDL2 \
    mingw-w64-i686-suitesparse \
+
mingw-w64-x86_64-suitesparse \
    mingw-w64-i686-vala \
+
mingw-w64-x86_64-xpm-nox
    mingw-w64-i686-xpm-nox
+
 
 +
 
 +
or if you have Windows 32 bit
 +
 
 +
pacman -S base-devel \
 +
mingw-w64-i686-toolchain \
 +
git \
 +
mingw-w64-i686-asciidoc \
 +
mingw-w64-i686-drmingw \
 +
mingw-w64-i686-gexiv2 \
 +
mingw-w64-i686-ghostscript \
 +
mingw-w64-i686-glib-networking \
 +
mingw-w64-i686-gobject-introspection \
 +
mingw-w64-i686-graphviz \
 +
mingw-w64-i686-gtk2 \
 +
mingw-w64-i686-iso-codes \
 +
mingw-w64-i686-json-c \
 +
mingw-w64-i686-json-glib \
 +
mingw-w64-i686-lcms2 \
 +
mingw-w64-i686-lensfun \
 +
mingw-w64-i686-libheif \
 +
mingw-w64-i686-libraw \
 +
mingw-w64-i686-libspiro \
 +
mingw-w64-i686-libwebp \
 +
mingw-w64-i686-libwmf \
 +
mingw-w64-i686-meson \
 +
mingw-w64-i686-openexr \
 +
mingw-w64-i686-poppler \
 +
mingw-w64-i686-python2-pygtk \
 +
mingw-w64-i686-SDL2 \
 +
mingw-w64-i686-suitesparse \
 +
mingw-w64-i686-xpm-nox</nowiki>
 +
 
 +
'''If you want to build gimp master'''
 +
<nowiki>
 +
If you have Windows 64 bit in this shell run:
 +
 
 +
pacman -S base-devel \
 +
mingw-w64-x86_64-toolchain \
 +
git \
 +
mingw-w64-x86_64-appstream-glib \
 +
mingw-w64-x86_64-asciidoc \
 +
mingw-w64-x86_64-drmingw \
 +
mingw-w64-x86_64-gexiv2 \
 +
mingw-w64-x86_64-ghostscript \
 +
mingw-w64-x86_64-glib-networking \
 +
mingw-w64-x86_64-gobject-introspection \
 +
mingw-w64-x86_64-graphviz \
 +
mingw-w64-x86_64-gtk3 \
 +
mingw-w64-x86_64-iso-codes \
 +
mingw-w64-x86_64-json-c \
 +
mingw-w64-x86_64-json-glib \
 +
mingw-w64-x86_64-lcms2 \
 +
mingw-w64-x86_64-lensfun \
 +
mingw-w64-x86_64-libarchive \
 +
mingw-w64-x86_64-libheif \
 +
mingw-w64-x86_64-libraw \
 +
mingw-w64-x86_64-libspiro \
 +
mingw-w64-x86_64-libwebp \
 +
mingw-w64-x86_64-libwmf \
 +
mingw-w64-x86_64-luajit \
 +
mingw-w64-x86_64-meson \
 +
mingw-w64-x86_64-openexr \
 +
mingw-w64-x86_64-poppler \
 +
mingw-w64-x86_64-python3-gobject \
 +
mingw-w64-x86_64-SDL2 \
 +
mingw-w64-x86_64-suitesparse \
 +
mingw-w64-x86_64-vala \
 +
mingw-w64-x86_64-xpm-nox
 +
 
 +
 
 +
or if you have Windows 32 bit
 +
 
 +
pacman -S base-devel \
 +
mingw-w64-i686-toolchain \
 +
git \
 +
mingw-w64-i686-appstream-glib \
 +
mingw-w64-i686-asciidoc \
 +
mingw-w64-i686-drmingw \
 +
mingw-w64-i686-gexiv2 \
 +
mingw-w64-i686-ghostscript \
 +
mingw-w64-i686-glib-networking \
 +
mingw-w64-i686-gobject-introspection \
 +
mingw-w64-i686-graphviz \
 +
mingw-w64-i686-gtk3 \
 +
mingw-w64-i686-iso-codes \
 +
mingw-w64-i686-json-c \
 +
mingw-w64-i686-json-glib \
 +
mingw-w64-i686-lcms2 \
 +
mingw-w64-i686-lensfun \
 +
mingw-w64-i686-libarchive \
 +
mingw-w64-i686-libheif \
 +
mingw-w64-i686-libraw \
 +
mingw-w64-i686-libspiro \
 +
mingw-w64-i686-libwebp \
 +
mingw-w64-i686-libwmf \
 +
mingw-w64-i686-luajit \
 +
mingw-w64-i686-meson \
 +
mingw-w64-i686-openexr \
 +
mingw-w64-i686-poppler \
 +
mingw-w64-i686-python3-gobject \
 +
mingw-w64-i686-SDL2 \
 +
mingw-w64-i686-suitesparse \
 +
mingw-w64-i686-vala \
 +
mingw-w64-i686-xpm-nox</nowiki>
  
 
Simply hit enter at the prompts for which packages to install (default=all). This step will download a ton of packages, and may take a while.
 
Simply hit enter at the prompts for which packages to install (default=all). This step will download a ton of packages, and may take a while.
 +
 +
Next, edit your .bash_profile, and add these lines:
 +
 +
<nowiki>
 +
export PREFIX=`realpath ~/prefix`
 +
export PATH="$PREFIX/bin:$PATH"
 +
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
 +
export PKG_CONFIG_PATH="$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
 +
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
 +
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$PREFIX/share:/usr/local/share/:/usr/share/"</nowiki>
 +
 +
If you have Windows 64 bit add
 +
 +
<nowiki>
 +
export ACLOCAL_FLAGS="-I/c/msys64/mingw64/share/aclocal"</nowiki>
 +
 +
If you like, you can also add this to .bash_profile:
 +
<nowiki>
 +
export MAKEFLAGS=-j4</nowiki>
 +
This will cause make to do a multi-core build, using the number of cores specified after the -j option.
 +
 +
Note: if you're comfortable in the terminal, you can simply use vi/vim: <code>vim .bash_profile</code>.<br/>
 +
Otherwise the file can be found in the msys2 install directory, by default: <code>C:\msys64\home\{USERNAME}\.bash_profile</code>
 +
 +
Now, reload your .bash_profile:
 +
 +
<nowiki>
 +
. .bash_profile</nowiki>
  
 
=== Building the software ===
 
=== Building the software ===
  
You can now just follow the instruction on the main page [[Hacking:Building]]. Just be careful of the following changes :
+
Libmypaint is a relatively new dependency for git-master.
  
* If you are on Windows 64bits, you may need to add an environment variable for Autotools :
+
  <nowiki>
  export ACLOCAL_FLAGS="-I/c/msys64/mingw64/share/aclocal"
+
git clone https://github.com/mypaint/libmypaint.git
 +
cd libmypaint
 +
git checkout tags/v1.3.0 #Use tag 1.3.0
 +
./autogen.sh
 +
./configure --prefix=$PREFIX
 +
make
 +
make install
 +
cd ..</nowiki>
  
* Use Libmypaint 1.3.0 (FIXME : should be updated ?). Download the 1.3.0 source tarball, or checkout the correct tag in <code>git</code> :
+
Mypaint-brushes:
git checkout tags/v1.3.0 #Use tag 1.3.0
+
  
* Use Mypaint-brushes 1.3.x. Download the 1.3.0 source tarball, or checkout the correct tag in <code>git</code> :
+
<nowiki>
git checkout v1.3.x
+
git clone https://github.com/mypaint/mypaint-brushes
 +
cd mypaint-brushes
 +
git checkout v1.3.x
 +
./autogen.sh
 +
./configure --prefix=$PREFIX
 +
make
 +
make install
 +
cd ..</nowiki>
  
* Disable docs for Babl : <code>-Dwith-docs=false</code> while calling Meson.
+
Now, prepare to build babl and gegl
  
* Disable docs for Gegl : <code>-Ddocs=false</code> while calling Meson.
+
<nowiki>
 +
mkdir -p build/babl
 +
mkdir build/gegl</nowiki>
  
  
You may want to disable the docs while building Gimp :  
+
<nowiki>
 +
git clone https://gitlab.gnome.org/GNOME/babl.git
 +
cd build/babl
 +
SRCDIR=../../babl
 +
meson -Dprefix=$PREFIX $SRCDIR -D with-docs=false
 +
ninja
 +
ninja install
 +
cd ../..</nowiki>
  
* Meson build : <code>-Dgtk-doc=false -Dgtk-doc-app=false</code>
+
Next, gegl from git.
* Autotools build : <code>--disable-docs</code>
+
  
== Cross-Compiling GIMP under UNIX using crossroad ==
+
<nowiki>
 +
git clone https://gitlab.gnome.org/GNOME/gegl.git
 +
cd build/gegl
 +
SRCDIR=../../gegl
 +
./autogen.sh --prefix=$PREFIX --enable-gtk-doc-html=no --disable-docs
 +
make
 +
make install
 +
cd ..</nowiki>
  
A tool named [https://pypi.python.org/pypi/crossroad crossroad] has been developed to cross-build for Windows under Linux (it was even originally started to crossbuild GIMP specifically).
+
and then gimp If you don't need the docs to be built, bypass them by adding <code>--disable-docs</code> to autogen:
  
See the [http://girinstud.io/news/2016/05/crossroad-0-6-released-cross-building-gimp-as-an-example/ tutorial explaining how to build GIMP with it].
+
<nowiki>
 +
git clone https://gitlab.gnome.org/GNOME/gimp.git
 +
cd gimp
 +
./autogen.sh --prefix=$PREFIX --disable-gtk-doc --with-gimpdir=GIMP/git-master --with-javascript=force --with-lua=force
 +
make
 +
make install
 +
cd ..</nowiki>
  
 +
Passing the option <code>--with-gimpdir=GIMP/git-master</code> will have this GIMP use a different settings folder.  This keeps it from interfering with other GIMP installations on the same computer.
 +
 +
By default, on Windows, this is will place the directory at: <code>C:\Users\patrickd\AppData\Roaming\GIMP\git-master</code>
 +
 +
If you want build gimp 2.10 you must replace
 +
 +
<nowiki>
 +
git clone https://gitlab.gnome.org/GNOME/gimp.git
 +
 +
with
 +
 +
git clone -b gimp-2-10 --single-branch https://gitlab.gnome.org/GNOME/gimp.git</nowiki>
 +
 +
 +
==== To Do ====
 +
Check the inclusion of python into the build.
 +
 +
=== Running GIMP ===
 +
 +
If everything worked up until now, you should be able to run GIMP like this:
 +
 +
for gimp 2.10
 +
<nowiki>
 +
gimp-2.10</nowiki>
 +
 +
and for master
 +
 +
<nowiki>
 +
gimp-2.99</nowiki>
 +
 +
== Building GIMP natively under Windows using MinGW ==
 +
 +
While the MSYS2 instructions above are the recommended method for compiling gimp on windows, you may find some of these older resources for compiling with plain mingw useful.
 +
MinGW is an open source Linux environment available on the Windows platform.
 +
 +
The following articles discuss building GIMP on and for the Windows platform using MinGW:
 +
 +
<strike>[http://partha.com/articles/groundwork.html Groundwork]</strike> by Partha Bagchi (404)
 +
 +
<strike>[http://partha.com/articles/buildinggimp.html Building GIMP for Windows]</strike> by Partha Bagchi (404)
 +
 +
<strike>[http://article.gmane.org/gmane.comp.video.gimp.devel/19203 Building GIMP and plug-ins for Windows]</strike> by Jernej Simončič (404)
 +
 +
[http://lightningismyname.blogspot.de/p/compiling-gimp.html Building GIMP for Linux and Windows] by Barak Itkin
 +
 +
 +
You find MinGW (the programming tool) and MSYS (a Bourne shell command line) at [http://www.mingw.org/ the MinGW website].
 +
 +
== Cross-Compiling GIMP under UNIX using crossroad ==
 +
 +
A tool named [https://pypi.python.org/pypi/crossroad crossroad] has been
 +
developed to cross-build for Windows under Linux (it was even originally started
 +
to crossbuild GIMP specifically).
 +
 +
See the
 +
[http://girinstud.io/news/2016/05/crossroad-0-6-released-cross-building-gimp-as-an-example/ tutorial explaining how to build GIMP with it].
 
Condensed, here is the process:
 
Condensed, here is the process:
  
crossroad w64 gimp-build
+
<code>
+
crossroad w64 gimp-build
crossroad install \
+
 
    glib2-devel \
+
crossroad install glib2-devel libexiv2-devel json-glib-devel libjpeg8-devel
    libexiv2-devel \
+
libpng-devel cairo-devel libtiff-devel librsvg-2-2 librsvg-devel pango-devel
    json-glib-devel \
+
libwebp5 libwebp-devel libjasper-devel gdk-pixbuf-devel libSDL-devel libjson-c2
    libjpeg8-devel \
+
libjson-c-devel atk-devel gtk2-devel libbz2-1 libbz2-devel liblzma-devel
    libpng-devel \
+
liblcms2-2 liblcms2-devel libgs8 libgs-devel libmng1 libmng-devel
    cairo-devel \
+
libpoppler-glib8 libpoppler-glib-devel poppler-data xpm-nox-devel headers
    libtiff-devel \
+
iso-codes-devel libwmf-devel libgexiv2-devel headers
    librsvg-2-2 \
+
 
    librsvg-devel \
+
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.29.tar.xz
    pango-devel \
+
 
    libwebp5 \
+
tar xf libpng-1.6.29.tar.xz && cd libpng-1.6.29 && crossroad configure && make && make install && cd ..
    libwebp-devel \
+
 
    libjasper-devel \
+
git clone git://git.gnome.org/babl
    gdk-pixbuf-devel \
+
 
    libSDL-devel \
+
cd babl && crossroad configure && make && make install && cd ..
    libjson-c2 \
+
 
    libjson-c-devel \
+
git clone git://git.gnome.org/gegl
    atk-devel \
+
 
    gtk2-devel \
+
cd gegl && crossroad configure && make && make install && cd ..
    libbz2-1 \
+
 
    libbz2-devel \
+
git clone https://github.com/mypaint/libmypaint.git
    liblzma-devel \
+
 
    liblcms2-2 \
+
cd libmypaint && crossroad configure && make && make install && cd ..
    liblcms2-devel \
+
 
    libgs8 \
+
git clone git://git.gnome.org/gimp
    libgs-devel \
+
 
    libmng1 \
+
cd gimp && crossroad configure --disable-python && make && make install
    libmng-devel \
+
</code>
    libpoppler-glib8 \
+
    libpoppler-glib-devel \
+
    poppler-data \
+
    xpm-nox-devel headers \
+
    iso-codes-devel \
+
    libwmf-devel \
+
    libgexiv2-devel headers
+
+
wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.29.tar.xz
+
tar xf libpng-1.6.29.tar.xz
+
pushd libpng-1.6.29
+
crossroad configure
+
make && make install
+
popd
+
+
git clone git://git.gnome.org/babl
+
pushd babl
+
crossroad configure
+
make && make install
+
popd
+
+
git clone git://git.gnome.org/gegl
+
pushd gegl
+
crossroad configure
+
make && make install
+
popd
+
+
git clone https://github.com/mypaint/libmypaint.git
+
cd libmypaint
+
crossroad configure
+
make && make install
+
popd
+
+
git clone git://git.gnome.org/gimp
+
crossroad configure --disable-python
+
make && make install
+
popd
+
  
 
Check out the full tutorial for more details.
 
Check out the full tutorial for more details.
  
Note: this is basically the same thing as the Mingw64 cross build, simply crossroad wraps all the complicated parts!
+
Note: this is basically the same thing as the next section, simply crossroad
 +
wraps all the complicated parts!
  
== Cross-Compiling GIMP under Linux using MinGW-w64 ==
+
== Cross-Compiling GIMP under UNIX using MinGW-w64 ==
  
Experience shows that working with the MinGW environment on a Linux machine provides a much faster compilation, and you are still able to compile for any Windows target (32 and 64 bits).
+
Experience shows that working with the MinGW environment on a UNIX machine provides a much faster compilation, and you are still able to compile for any Windows target (32 and 64 bits).
  
 
NOTE: the following procedure should be distribution-independent and does not rely on your package management system, even though it uses some OpenSuse packages. It would probably work on OSX or any other UNIX as well (add a note on the list below if you know this procedure works on another OS).
 
NOTE: the following procedure should be distribution-independent and does not rely on your package management system, even though it uses some OpenSuse packages. It would probably work on OSX or any other UNIX as well (add a note on the list below if you know this procedure works on another OS).
Line 272: Line 373:
  
 
''Source of the original procedure from an [https://mail.gnome.org/archives/gimp-developer-list/2012-May/msg00067.html email by Victor Oliveira].''
 
''Source of the original procedure from an [https://mail.gnome.org/archives/gimp-developer-list/2012-May/msg00067.html email by Victor Oliveira].''
 +
 +
=== Create a separate environment prefix ===
 +
 +
You obviously don't want to mix your Windows binaries with your normal distribution (and also you want to avoid ever having to use ''root'').
 +
For instance you can choose:
 +
 +
<code>
 +
$ mkdir $HOME/w64/
 +
 +
$ cd $HOME/w64
 +
</code>
  
 
=== Install mingw-w64 ===
 
=== Install mingw-w64 ===
This procedure relies on the newer [http://mingw-w64.sourceforge.net/ MinGW-w64] project.
 
  
If your distribution provides the <code>mingw-w64</code> tools, you may install them with your package manager.
+
The original [http://www.mingw.org/wiki/LinuxCrossMinGW MinGW] projects can only compile for Windows 32 bits. Hence this procedure relies on the newer [http://mingw-w64.sourceforge.net/ MinGW-w64] project.
  
Otherwise, download directly the last release [https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release on Sourceforge].
+
If your distribution provides the mingw-w64 tools, you may install them with your package manager. Otherwise you can download directly on SourceForge the last [http://sourceforge.net/apps/trac/mingw-w64/wiki/download%20filename%20structure daily snapshot] from the project.
  
The archive contains a prefix tree, that you can consider as read-only (just like your linux system).
+
For instance if you are on Linux 64 bits and want to compile for Windows 64 bits, you should download '''mingw-w64-bin_x86_64-linux_20121031.tar.bz2'''.
 +
Note that you can install alongside '''mingw-w32-bin_x86_64-linux_20121031.tar.bz2''' if you want to be able to cross-compile for Windows 32 bits as well.
 +
 
 +
<code>$ tar xjf mingw-w64-bin_x86_64-linux_20121031.tar.bz2</code>
 +
 
 +
This will extract all the cross-compiling tools and generate a prefix tree inside your $HOME/w64 directory.
  
 
=== Install GIMP Dependencies ===
 
=== Install GIMP Dependencies ===
  
 
The default environment provided by MinGW does not have the huge list of dependencies that GIMP requires.
 
The default environment provided by MinGW does not have the huge list of dependencies that GIMP requires.
 
 
Fortunately the [https://mail.gnome.org/archives/gimp-developer-list/2012-May/msg00067.html email] linked above has bash script named '''grab-stuff.sh''' (which calls itself a python3 script named "download-mingw-rpm.py", so you have to download both and have python3), which downloads pre-compiled version of all needed dependencies for cross-compiling (it uses OpenSuse repositories as source, but it does not mean at all you need rpm support).
 
Fortunately the [https://mail.gnome.org/archives/gimp-developer-list/2012-May/msg00067.html email] linked above has bash script named '''grab-stuff.sh''' (which calls itself a python3 script named "download-mingw-rpm.py", so you have to download both and have python3), which downloads pre-compiled version of all needed dependencies for cross-compiling (it uses OpenSuse repositories as source, but it does not mean at all you need rpm support).
  
 
From the root of your cross-compiling prefix ($HOME/w64) run:
 
From the root of your cross-compiling prefix ($HOME/w64) run:
bash grab-stuff.sh
 
  
You will notice in particular a new usr/ folder, and inside i686-w64-mingw32/ and x86_64-w64-mingw32/ sub-folders.
+
<code>$ bash grab-stuff.sh</code>
  
TODO : Make a proper dependency list.
+
You will notice in particular a new usr/ folder, and inside i686-w64-mingw32/ and x86_64-w64-mingw32/ sub-folders.
  
 
=== Set your cross-compiling environment ===
 
=== Set your cross-compiling environment ===
  
1. Choose your target
+
1. Choose your target:
# For 32-bits :
+
 
export HOST=i686-w64-mingw32
+
For building Windows 32 bits executables:
# or for 64-bits :
+
 
export HOST=x86_64-w64-mingw32
+
<code>$ export HOST=i686-w64-mingw32</code>
 +
 
 +
For building Windows 64 bits executables:
 +
 
 +
<code>$ export HOST=x86_64-w64-mingw32</code>
 +
 
  
 
2. Create a dependencies prefix:
 
2. Create a dependencies prefix:
export DEP_PREFIX=$HOME/w64/usr/$HOST/sys-root/mingw
+
 
 +
<code>$ export DEP_PREFIX=$HOME/w64/usr/$HOST/sys-root/mingw</code>
 +
 
  
 
3. Create an installation prefix, that you chose earlier:
 
3. Create an installation prefix, that you chose earlier:
export PREFIX=$HOME/w64
+
 
 +
<code>$ export PREFIX=$HOME/w64</code>
 +
 
  
 
4. You don't want any library linked from your normal Linux environment, so let's reset pkg-config:
 
4. You don't want any library linked from your normal Linux environment, so let's reset pkg-config:
export PKG_CONFIG_LIBDIR=
+
 
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$DEP_PREFIX/lib/pkgconfig
+
<code>$ export PKG_CONFIG_LIBDIR=</code>
export LD_LIBRARY_PATH=$PREFIX/lib:$DEP_PREFIX/lib
+
 
 +
<code>$ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$DEP_PREFIX/lib/pkgconfig</code>
 +
 
 +
<code>$ export LD_LIBRARY_PATH=$PREFIX/lib:$DEP_PREFIX/lib</code>
 +
 
  
 
5. Used tools though may still use the old path as well, but preferably the downloaded MinGW.  
 
5. Used tools though may still use the old path as well, but preferably the downloaded MinGW.  
 +
 
NOTE: This step is useless if you installed MinGW-w64 from your distribution.
 
NOTE: This step is useless if you installed MinGW-w64 from your distribution.
export PATH=$PREFIX/bin:$DEP_PREFIX/bin:$PATH
+
 
 +
<code>$ export PATH=$PREFIX/bin:$DEP_PREFIX/bin:$PATH</code>
 +
 
  
 
6. Let GEGLs and GIMPs configure scripts find JPEG, MNG and EXIF2 support. If you set this, you won't need the ''--without-libjpeg'' option in GIMPs configure step:
 
6. Let GEGLs and GIMPs configure scripts find JPEG, MNG and EXIF2 support. If you set this, you won't need the ''--without-libjpeg'' option in GIMPs configure step:
export C_INCLUDE_PATH=$DEP_PREFIX/include
+
 
 +
<code>$ export C_INCLUDE_PATH=$DEP_PREFIX/include</code>
 +
 
  
 
7. Finally let's add some compilation flags:
 
7. Finally let's add some compilation flags:
export ACLOCAL_FLAGS="-I $DEP_PREFIX/share/aclocal"
+
 
export CFLAGS="-I$DEP_PREFIX/include -I$PREFIX/include"
+
<code>$ export ACLOCAL_FLAGS="-I $DEP_PREFIX/share/aclocal"</code>
export CPATH="$DEP_PREFIX/include:$PREFIX/include"
+
 
export LDFLAGS="-L$DEP_PREFIX/lib -L$PREFIX/lib"
+
<code>$ export CFLAGS="-I$DEP_PREFIX/include -I$PREFIX/include"</code>
 +
 
 +
<code>$ export CPATH="$DEP_PREFIX/include:$PREFIX/include"</code>
 +
 
 +
<code>$ export LDFLAGS="-L$DEP_PREFIX/lib -L$PREFIX/lib"</code>
  
 
NOTE: If you installed MinGW-w64 from your distribution, the ''"-L$DEP_PREFIX/lib"'' or ''"-I$DEP_PREFIX/include"'' will have to be replaced by your
 
NOTE: If you installed MinGW-w64 from your distribution, the ''"-L$DEP_PREFIX/lib"'' or ''"-I$DEP_PREFIX/include"'' will have to be replaced by your
Line 335: Line 471:
  
 
=== Build BABL ===
 
=== Build BABL ===
git clone git://git.gnome.org/babl
+
 
cd babl
+
You can use released versions if they have a version big enough. As the time of writing this, GIMP from git requires BABL and GEGL from git as well.
./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no
+
<code>
make
+
$ cd src/
make install
+
 
 +
$ git clone git://git.gnome.org/babl
 +
 
 +
$ cd babl
 +
 
 +
$ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no
 +
 
 +
$ make
 +
 
 +
$ make install
 +
</code>
  
 
=== Build GEGL ===
 
=== Build GEGL ===
git clone git://git.gnome.org/gegl
+
<code>
cd gegl
+
1. $ cd ..
  ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no --disable-docs --disable-glibtest
+
 
make
+
2. $ git clone git://git.gnome.org/gegl
make install
+
 
 +
3. $ cd gegl
 +
 
 +
</code>
 +
 
 +
4. Checkout the right branch from your GEGL git repository.
 +
 
 +
:For GIMP 2.8: <code> $ git checkout gegl-0-2 </code>
 +
 
 +
:For the latest development version of GIMP:  <code>$ git checkout master</code>
 +
 
 +
<code>
 +
5. $ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no --disable-docs --disable-glibtest
 +
 
 +
6. $ make
 +
 
 +
7. $ make install
 +
</code>
  
 
=== Build any optional dependency ===
 
=== Build any optional dependency ===
Line 357: Line 520:
 
In my case xz-5.0.4 worked well.
 
In my case xz-5.0.4 worked well.
  
cd ..
+
<code>
wget http://tukaani.org/xz/xz-5.0.4.tar.xz
+
$ cd ..
tar xf xz-5.0.4.tar.xz
+
 
rm xz-5.0.4.tar.xz
+
$ wget http://tukaani.org/xz/xz-5.0.4.tar.xz
cd xz-5.0.4
+
 
./configure --prefix=$PREFIX --host=$HOST
+
$ tar xf xz-5.0.4.tar.xz
make
+
 
make install
+
$ rm xz-5.0.4.tar.xz
 +
 
 +
$ cd xz-5.0.4
 +
 
 +
$ ./configure --prefix=$PREFIX --host=$HOST
 +
 
 +
$ make
 +
 
 +
$ make install
 +
</code>
  
 
Finally obviously in the GIMP configure step, remove the ''--without-liblzma'' option on the autogen.sh command line before compiling GIMP.
 
Finally obviously in the GIMP configure step, remove the ''--without-liblzma'' option on the autogen.sh command line before compiling GIMP.
Line 385: Line 557:
 
=== Build GIMP ===
 
=== Build GIMP ===
  
cd ..
+
<code>
git clone git://git.gnome.org/gimp
+
$ cd ..
cd gimp
+
 
./autogen.sh --prefix=$PREFIX --host=$HOST \
+
$ git clone git://git.gnome.org/gimp
    --enable-introspection=no \
+
 
    --disable-glibtest \
+
$ cd gimp
    --disable-gtktest \
+
 
    --disable-docs \
+
$ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no --disable-glibtest --disable-gtktest --disable-docs --without-libjpeg --disable-python --without-xmc --without-dbus --without-libzma
    --without-libjpeg \
+
 
    --disable-python \
+
$ make
    --without-xmc \
+
 
    --without-dbus \
+
$ make install
    --without-libzma \
+
</code>
make
+
make install
+
  
 
=== Install On Windows ===
 
=== Install On Windows ===
Line 450: Line 620:
 
3. Restart GIMP.
 
3. Restart GIMP.
  
== Troubleshooting ==
+
== Cross-Compiling GIMP under UNIX using crossroad ==
  
==== Running gimp-2.x.exe on Windows fails. Error messages about a missing entry point in libglib-2.0-0.dll or a missing bzip2.dll are shown.====
+
This is basically the same procedure as "[[#Cross Compiling GIMP under UNIX using MinGW-w64]]", but wrapped in a tool called `crossroad`, which makes it easier because there is no "magic" to remember (like the host and target syntaxes, etc.) and also because the dependency handling is done through an installer tool, similar to usual package managers.
'''Cause:'''
+
Check this [https://mail.gnome.org/archives/gimp-developer-list/2013-October/msg00108.html email] where the procedure is explained for a full GIMP build with crossroad, and install [https://pypi.python.org/pypi/crossroad crossroad] from pypi.
 
+
The missing dll files are in the MinGW binary folder, which is separate from the GIMP folders.
+
 
+
'''Solution:'''
+
 
+
To export the GIMP build to Windows properly, use the following steps:
+
 
+
1. On Windows create a folder for the GIMP build, like GIMP-Master.
+
 
+
2. Copy all files from $HOME/w64/$HOST/sys-root/mingw to the newly created folder.
+
 
+
3. Copy all files from your $PREFIX folder to the newly created folder. There are duplicate subfolders, for instance bin, share etc., in both directories. If your filemanager asks you to overwrite them, then confirm.
+
 
+
It's important to keep this order to ensure you overwrite older BABL and GEGL from the grab-stuff.sh script by the newer ones from your build.
+
 
+
At the end you have merged your MinGW installation and the GIMP build to a running GIMP on Windows build.
+
(It also contains the unnecessary MinGW binaries, which are not needed anymore to run GIMP. But for testing purposes you have a running GIMP installation.)
+
 
+
==== Some fonts, like Sans, are shown improperly ====
+
See also [https://bugzilla.gnome.org/show_bug.cgi?id=688593 the Bugzilla report].
+
 
+
'''Cause:'''
+
 
+
The fontconfig package installation writes absolute paths of the building system to fonts.conf and conf.d/*.conf. When GIMP is installed on the Windows target system, these absolute paths become invalid.
+
 
+
'''Solution:'''
+
 
+
The bug should be reported to the Fontconfig developers. Meanwhile do on the Windows target system:
+
 
+
1. Close GIMP.
+
 
+
2. Edit the file ''<GIMP installation folder>\etc\fonts\fonts.conf'':
+
 
+
Replace the line <code><include ignore_missing="yes">$a_directory/conf.d</include></code> by <code><include ignore_missing="yes">..\..\share\fontconfig\conf.avail</include></code>
+
 
+
3. Restart GIMP.
+
  
 
== Building GIMP using Microsoft tools ==
 
== Building GIMP using Microsoft tools ==

Revision as of 19:39, 21 November 2019

A developer can build and develop GIMP using Windows. One reason to do so is to fix any GIMP bugs specific to the Windows platform. However, there is already a package of GIMP for Windows (at: GIMP Windows installers by Jernej Simončič.). A GIMP debugger or developer would still need to submit patches to the GIMP development team.

Note: the instructions are not always kept up to date; check on irc.gnome.org #gimp first if you are not sure. The primary development platform is the Debian Testing GNU/Linux distribution, so the very latest code from GIT might not always build on other platforms.

Building GIMP natively under Windows using MSYS2

As 6/1/2019 you can build only the Gimp 2.10 branch due missing dependences on master branch

Setting up a devel environment

First, follow the installation instructions for msys2 available at msys2.github.io.

Make sure to follow the post-installation instructions on that page to update the msys2, mingw64, mingw32 systems appropriately. This includes:

  • Updating pacman and the package database:
pacman -Sy pacman
  • If needed, close MSYS2 and run it again (note: the installed .bat files don't appear to work on win10, launch it directly from the install location, ie: c:\msys2\msys2.exe).
    Update the package database and core system packages:
pacman -Syu

If an error is thrown about incompatible versions of the cygwin DLL and the following warnings are shown:

warning: terminate MSYS2 without returning to shell and check for updates again
warning: for example close your terminal window instead of calling exit

Then follow the instructions and close the terminal window (it may warn you of running processes, choose "OK" to close it anyway).

Re-open MSYS2 from the install directory by running msys2_shell.cmd, and re-run the update command pacman -Syu.

  • If needed, close MSYS2 and run it again (again).
    Finally update the rest with one more call:
pacman -Su

Once everything is updated, exit out of MSYS2.

The shortcut for running mingw64, called "MinGW-w64 Win64 Shell" won't work after the update.

Run mingw64.exe directly from the install directory (by default: c:\msys64\mingw64.exe or c:\msys32\mingw32.exe).

If you want to build gimp 2.10

If you have Windows 64 bit in this shell run:

pacman -S base-devel \
mingw-w64-x86_64-toolchain \
git \
mingw-w64-x86_64-asciidoc \
mingw-w64-x86_64-drmingw \
mingw-w64-x86_64-gexiv2 \
mingw-w64-x86_64-ghostscript \
mingw-w64-x86_64-glib-networking \
mingw-w64-x86_64-gobject-introspection \
mingw-w64-x86_64-graphviz \
mingw-w64-x86_64-gtk2 \
mingw-w64-x86_64-iso-codes \
mingw-w64-x86_64-json-c \
mingw-w64-x86_64-json-glib \
mingw-w64-x86_64-lcms2 \
mingw-w64-x86_64-lensfun \
mingw-w64-x86_64-libheif \
mingw-w64-x86_64-libraw \
mingw-w64-x86_64-libspiro \
mingw-w64-x86_64-libwebp \
mingw-w64-x86_64-libwmf \
mingw-w64-x86_64-meson \
mingw-w64-x86_64-openexr \
mingw-w64-x86_64-poppler \
mingw-w64-x86_64-python2-pygtk \
mingw-w64-x86_64-SDL2 \
mingw-w64-x86_64-suitesparse \
mingw-w64-x86_64-xpm-nox


or if you have Windows 32 bit

pacman -S base-devel \
mingw-w64-i686-toolchain \
git \
mingw-w64-i686-asciidoc \
mingw-w64-i686-drmingw \
mingw-w64-i686-gexiv2 \
mingw-w64-i686-ghostscript \
mingw-w64-i686-glib-networking \
mingw-w64-i686-gobject-introspection \
mingw-w64-i686-graphviz \
mingw-w64-i686-gtk2 \
mingw-w64-i686-iso-codes \
mingw-w64-i686-json-c \
mingw-w64-i686-json-glib \
mingw-w64-i686-lcms2 \
mingw-w64-i686-lensfun \
mingw-w64-i686-libheif \
mingw-w64-i686-libraw \
mingw-w64-i686-libspiro \
mingw-w64-i686-libwebp \
mingw-w64-i686-libwmf \
mingw-w64-i686-meson \
mingw-w64-i686-openexr \
mingw-w64-i686-poppler \
mingw-w64-i686-python2-pygtk \
mingw-w64-i686-SDL2 \
mingw-w64-i686-suitesparse \
mingw-w64-i686-xpm-nox

If you want to build gimp master

If you have Windows 64 bit in this shell run:

pacman -S base-devel \
mingw-w64-x86_64-toolchain \
git \
mingw-w64-x86_64-appstream-glib \
mingw-w64-x86_64-asciidoc \
mingw-w64-x86_64-drmingw \
mingw-w64-x86_64-gexiv2 \
mingw-w64-x86_64-ghostscript \
mingw-w64-x86_64-glib-networking \
mingw-w64-x86_64-gobject-introspection \
mingw-w64-x86_64-graphviz \
mingw-w64-x86_64-gtk3 \
mingw-w64-x86_64-iso-codes \
mingw-w64-x86_64-json-c \
mingw-w64-x86_64-json-glib \
mingw-w64-x86_64-lcms2 \
mingw-w64-x86_64-lensfun \
mingw-w64-x86_64-libarchive \
mingw-w64-x86_64-libheif \
mingw-w64-x86_64-libraw \
mingw-w64-x86_64-libspiro \
mingw-w64-x86_64-libwebp \
mingw-w64-x86_64-libwmf \
mingw-w64-x86_64-luajit \
mingw-w64-x86_64-meson \
mingw-w64-x86_64-openexr \
mingw-w64-x86_64-poppler \
mingw-w64-x86_64-python3-gobject \
mingw-w64-x86_64-SDL2 \
mingw-w64-x86_64-suitesparse \
mingw-w64-x86_64-vala \
mingw-w64-x86_64-xpm-nox


or if you have Windows 32 bit

pacman -S base-devel \
mingw-w64-i686-toolchain \
git \
mingw-w64-i686-appstream-glib \
mingw-w64-i686-asciidoc \
mingw-w64-i686-drmingw \
mingw-w64-i686-gexiv2 \
mingw-w64-i686-ghostscript \
mingw-w64-i686-glib-networking \
mingw-w64-i686-gobject-introspection \
mingw-w64-i686-graphviz \
mingw-w64-i686-gtk3 \
mingw-w64-i686-iso-codes \
mingw-w64-i686-json-c \
mingw-w64-i686-json-glib \
mingw-w64-i686-lcms2 \
mingw-w64-i686-lensfun \
mingw-w64-i686-libarchive \
mingw-w64-i686-libheif \
mingw-w64-i686-libraw \
mingw-w64-i686-libspiro \
mingw-w64-i686-libwebp \
mingw-w64-i686-libwmf \
mingw-w64-i686-luajit \
mingw-w64-i686-meson \
mingw-w64-i686-openexr \
mingw-w64-i686-poppler \
mingw-w64-i686-python3-gobject \
mingw-w64-i686-SDL2 \
mingw-w64-i686-suitesparse \
mingw-w64-i686-vala \
mingw-w64-i686-xpm-nox

Simply hit enter at the prompts for which packages to install (default=all). This step will download a ton of packages, and may take a while.

Next, edit your .bash_profile, and add these lines:

export PREFIX=`realpath ~/prefix`
export PATH="$PREFIX/bin:$PATH"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
export PKG_CONFIG_PATH="$PREFIX/share/pkgconfig:$PKG_CONFIG_PATH"
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
export XDG_DATA_DIRS="$XDG_DATA_DIRS:$PREFIX/share:/usr/local/share/:/usr/share/"

If you have Windows 64 bit add

export ACLOCAL_FLAGS="-I/c/msys64/mingw64/share/aclocal"

If you like, you can also add this to .bash_profile:

export MAKEFLAGS=-j4

This will cause make to do a multi-core build, using the number of cores specified after the -j option.

Note: if you're comfortable in the terminal, you can simply use vi/vim: vim .bash_profile.
Otherwise the file can be found in the msys2 install directory, by default: C:\msys64\home\{USERNAME}\.bash_profile

Now, reload your .bash_profile:

. .bash_profile

Building the software

Libmypaint is a relatively new dependency for git-master.

git clone https://github.com/mypaint/libmypaint.git
cd libmypaint
git checkout tags/v1.3.0 #Use tag 1.3.0
./autogen.sh 
./configure --prefix=$PREFIX
make
make install
cd ..

Mypaint-brushes:

git clone https://github.com/mypaint/mypaint-brushes
cd mypaint-brushes
git checkout v1.3.x
./autogen.sh
./configure --prefix=$PREFIX
make
make install
cd ..

Now, prepare to build babl and gegl

mkdir -p build/babl
mkdir build/gegl


git clone https://gitlab.gnome.org/GNOME/babl.git
cd build/babl
SRCDIR=../../babl
meson -Dprefix=$PREFIX $SRCDIR -D with-docs=false
ninja
ninja install
cd ../..

Next, gegl from git.

git clone https://gitlab.gnome.org/GNOME/gegl.git
cd build/gegl
SRCDIR=../../gegl
./autogen.sh --prefix=$PREFIX --enable-gtk-doc-html=no --disable-docs
make
make install
cd ..

and then gimp If you don't need the docs to be built, bypass them by adding --disable-docs to autogen:

git clone https://gitlab.gnome.org/GNOME/gimp.git
cd gimp
./autogen.sh --prefix=$PREFIX --disable-gtk-doc --with-gimpdir=GIMP/git-master --with-javascript=force --with-lua=force
make
make install
cd ..

Passing the option --with-gimpdir=GIMP/git-master will have this GIMP use a different settings folder. This keeps it from interfering with other GIMP installations on the same computer.

By default, on Windows, this is will place the directory at: C:\Users\patrickd\AppData\Roaming\GIMP\git-master

If you want build gimp 2.10 you must replace

git clone https://gitlab.gnome.org/GNOME/gimp.git

with

git clone -b gimp-2-10 --single-branch https://gitlab.gnome.org/GNOME/gimp.git


To Do

Check the inclusion of python into the build.

Running GIMP

If everything worked up until now, you should be able to run GIMP like this:

for gimp 2.10

gimp-2.10

and for master

gimp-2.99

Building GIMP natively under Windows using MinGW

While the MSYS2 instructions above are the recommended method for compiling gimp on windows, you may find some of these older resources for compiling with plain mingw useful. MinGW is an open source Linux environment available on the Windows platform.

The following articles discuss building GIMP on and for the Windows platform using MinGW:

Groundwork by Partha Bagchi (404)

Building GIMP for Windows by Partha Bagchi (404)

Building GIMP and plug-ins for Windows by Jernej Simončič (404)

Building GIMP for Linux and Windows by Barak Itkin


You find MinGW (the programming tool) and MSYS (a Bourne shell command line) at the MinGW website.

Cross-Compiling GIMP under UNIX using crossroad

A tool named crossroad has been developed to cross-build for Windows under Linux (it was even originally started to crossbuild GIMP specifically).

See the tutorial explaining how to build GIMP with it. Condensed, here is the process:

crossroad w64 gimp-build

crossroad install glib2-devel libexiv2-devel json-glib-devel libjpeg8-devel libpng-devel cairo-devel libtiff-devel librsvg-2-2 librsvg-devel pango-devel libwebp5 libwebp-devel libjasper-devel gdk-pixbuf-devel libSDL-devel libjson-c2 libjson-c-devel atk-devel gtk2-devel libbz2-1 libbz2-devel liblzma-devel liblcms2-2 liblcms2-devel libgs8 libgs-devel libmng1 libmng-devel libpoppler-glib8 libpoppler-glib-devel poppler-data xpm-nox-devel headers iso-codes-devel libwmf-devel libgexiv2-devel headers

wget http://prdownloads.sourceforge.net/libpng/libpng-1.6.29.tar.xz

tar xf libpng-1.6.29.tar.xz && cd libpng-1.6.29 && crossroad configure && make && make install && cd ..

git clone git://git.gnome.org/babl

cd babl && crossroad configure && make && make install && cd ..

git clone git://git.gnome.org/gegl

cd gegl && crossroad configure && make && make install && cd ..

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

cd libmypaint && crossroad configure && make && make install && cd ..

git clone git://git.gnome.org/gimp

cd gimp && crossroad configure --disable-python && make && make install

Check out the full tutorial for more details.

Note: this is basically the same thing as the next section, simply crossroad wraps all the complicated parts!

Cross-Compiling GIMP under UNIX using MinGW-w64

Experience shows that working with the MinGW environment on a UNIX machine provides a much faster compilation, and you are still able to compile for any Windows target (32 and 64 bits).

NOTE: the following procedure should be distribution-independent and does not rely on your package management system, even though it uses some OpenSuse packages. It would probably work on OSX or any other UNIX as well (add a note on the list below if you know this procedure works on another OS).

Has been known to work on at least: Linux Mint 15, Ubuntu 12.04LST and Mageia 2 distributions.

Source of the original procedure from an email by Victor Oliveira.

Create a separate environment prefix

You obviously don't want to mix your Windows binaries with your normal distribution (and also you want to avoid ever having to use root). For instance you can choose:

$ mkdir $HOME/w64/

$ cd $HOME/w64

Install mingw-w64

The original MinGW projects can only compile for Windows 32 bits. Hence this procedure relies on the newer MinGW-w64 project.

If your distribution provides the mingw-w64 tools, you may install them with your package manager. Otherwise you can download directly on SourceForge the last daily snapshot from the project.

For instance if you are on Linux 64 bits and want to compile for Windows 64 bits, you should download mingw-w64-bin_x86_64-linux_20121031.tar.bz2. Note that you can install alongside mingw-w32-bin_x86_64-linux_20121031.tar.bz2 if you want to be able to cross-compile for Windows 32 bits as well.

$ tar xjf mingw-w64-bin_x86_64-linux_20121031.tar.bz2

This will extract all the cross-compiling tools and generate a prefix tree inside your $HOME/w64 directory.

Install GIMP Dependencies

The default environment provided by MinGW does not have the huge list of dependencies that GIMP requires. Fortunately the email linked above has bash script named grab-stuff.sh (which calls itself a python3 script named "download-mingw-rpm.py", so you have to download both and have python3), which downloads pre-compiled version of all needed dependencies for cross-compiling (it uses OpenSuse repositories as source, but it does not mean at all you need rpm support).

From the root of your cross-compiling prefix ($HOME/w64) run:

$ bash grab-stuff.sh

You will notice in particular a new usr/ folder, and inside i686-w64-mingw32/ and x86_64-w64-mingw32/ sub-folders.

Set your cross-compiling environment

1. Choose your target:

For building Windows 32 bits executables:

$ export HOST=i686-w64-mingw32

For building Windows 64 bits executables:

$ export HOST=x86_64-w64-mingw32


2. Create a dependencies prefix:

$ export DEP_PREFIX=$HOME/w64/usr/$HOST/sys-root/mingw


3. Create an installation prefix, that you chose earlier:

$ export PREFIX=$HOME/w64


4. You don't want any library linked from your normal Linux environment, so let's reset pkg-config:

$ export PKG_CONFIG_LIBDIR=

$ export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig:$DEP_PREFIX/lib/pkgconfig

$ export LD_LIBRARY_PATH=$PREFIX/lib:$DEP_PREFIX/lib


5. Used tools though may still use the old path as well, but preferably the downloaded MinGW.

NOTE: This step is useless if you installed MinGW-w64 from your distribution.

$ export PATH=$PREFIX/bin:$DEP_PREFIX/bin:$PATH


6. Let GEGLs and GIMPs configure scripts find JPEG, MNG and EXIF2 support. If you set this, you won't need the --without-libjpeg option in GIMPs configure step:

$ export C_INCLUDE_PATH=$DEP_PREFIX/include


7. Finally let's add some compilation flags:

$ export ACLOCAL_FLAGS="-I $DEP_PREFIX/share/aclocal"

$ export CFLAGS="-I$DEP_PREFIX/include -I$PREFIX/include"

$ export CPATH="$DEP_PREFIX/include:$PREFIX/include"

$ export LDFLAGS="-L$DEP_PREFIX/lib -L$PREFIX/lib"

NOTE: If you installed MinGW-w64 from your distribution, the "-L$DEP_PREFIX/lib" or "-I$DEP_PREFIX/include" will have to be replaced by your distribution default profile, likely respectively "-L/usr/x86_64-w64-mingw32/lib" and "-I/usr/x86_64-w64-mingw32/include".


8. You will probably want to save these values if you have to cross-compile again for Windows. The best is to save them in a file "env-64.sh" (and env-32.sh), that you can source at anytime.

Build BABL

You can use released versions if they have a version big enough. As the time of writing this, GIMP from git requires BABL and GEGL from git as well. $ cd src/

$ git clone git://git.gnome.org/babl

$ cd babl

$ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no

$ make

$ make install

Build GEGL

1. $ cd ..

2. $ git clone git://git.gnome.org/gegl

3. $ cd gegl

4. Checkout the right branch from your GEGL git repository.

For GIMP 2.8: $ git checkout gegl-0-2
For the latest development version of GIMP: $ git checkout master

5. $ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no --disable-docs --disable-glibtest

6. $ make

7. $ make install

Build any optional dependency

This step is not necessary if you compile GIMP with the minimum set of dependency as indicated at the next section.

Compression support

Nevertheless if for instance, you needed compression support (hence be able to load and save your images in various compressed format), you would need zlib,libbzip2 and liblzma installed. In particular the cross-compilation environment described on this page has no pre-compiled liblzma. You would need to cross-compile it first yourself.

In my case xz-5.0.4 worked well.

$ cd ..

$ wget http://tukaani.org/xz/xz-5.0.4.tar.xz

$ tar xf xz-5.0.4.tar.xz

$ rm xz-5.0.4.tar.xz

$ cd xz-5.0.4

$ ./configure --prefix=$PREFIX --host=$HOST

$ make

$ make install

Finally obviously in the GIMP configure step, remove the --without-liblzma option on the autogen.sh command line before compiling GIMP.

You should be able to do similar things for other optional features that you would want on your cross-compiled GIMP.

Alternatively there exists a patch to get compression support working in 32 bit builds.

Multi-Language support

Multi-Language support is installed with the grab-stuff.sh script. Due to a bug in the package mingw32-iso-codes-devel the pkgconfig program can't find the iso-codes package. In this case you will notice, that GIMPs autogen.sh reports

Language selection: no

and the finished GIMP build has no language selector listbox in Edit/Preferences/Interface. To solve this, copy $HOME/w64/usr/$HOST/sys-root/mingw/share/pkgconfig/iso-codes.pc to $HOME/w64/usr/$HOST/sys-root/mingw/lib/pkgconfig before executing autogen.sh or configure for GIMP. Note you have to do this for every value of $HOST you want to build (e.g. i686 and x86_64 architecture). Also merge the MinGW and GIMP build folders when installing it on Windows (see the Troubleshooting section).

Build GIMP

$ cd ..

$ git clone git://git.gnome.org/gimp

$ cd gimp

$ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no --disable-glibtest --disable-gtktest --disable-docs --without-libjpeg --disable-python --without-xmc --without-dbus --without-libzma

$ make

$ make install

Install On Windows

To test your compiled installation, I found nothing better than moving the whole tree (in my case $HOME/w64) into Windows, because libraries are dynamically linked, then run $HOME/w64/bin/gimp-2.9.exe under Windows.

If you really want to build a self contained GIMP, you should compile everything as static libraries. GIMP will probably still rely on some external files though, for instance what you find under $HOME/w64/share/gimp/2.0/. Maybe other things. But this will have to be tested if needed.


Troubleshooting

Running gimp-2.x.exe on Windows fails. Error messages about a missing entry point in libglib-2.0-0.dll or a missing bzip2.dll are shown.

Cause:

The missing dll files are in the MinGW binary folder, which is separate from the GIMP folders.

Solution:

To export the GIMP build to Windows properly, use the following steps:

1. On Windows create a folder for the GIMP build, like GIMP-Master.

2. Copy all files from $HOME/w64/$HOST/sys-root/mingw to the newly created folder.

3. Copy all files from your $PREFIX folder to the newly created folder. There are duplicate subfolders, for instance bin, share etc., in both directories. If your filemanager asks you to overwrite them, then confirm.

It's important to keep this order to ensure you overwrite older BABL and GEGL from the grab-stuff.sh script by the newer ones from your build.

At the end you have merged your MinGW installation and the GIMP build to a running GIMP on Windows build. (It also contains the unnecessary MinGW binaries, which are not needed anymore to run GIMP. But for testing purposes you have a running GIMP installation.)

Some fonts, like Sans, are shown improperly

See also the Bugzilla report.

Cause:

The fontconfig package installation writes absolute paths of the building system to fonts.conf and conf.d/*.conf. When GIMP is installed on the Windows target system, these absolute paths become invalid.

Solution:

The bug should be reported to the Fontconfig developers. Meanwhile do on the Windows target system:

1. Close GIMP.

2. Edit the file <GIMP installation folder>\etc\fonts\fonts.conf:

Replace the line <include ignore_missing="yes">$a_directory/conf.d</include> by <include ignore_missing="yes">..\..\share\fontconfig\conf.avail</include>

3. Restart GIMP.

Cross-Compiling GIMP under UNIX using crossroad

This is basically the same procedure as "#Cross Compiling GIMP under UNIX using MinGW-w64", but wrapped in a tool called `crossroad`, which makes it easier because there is no "magic" to remember (like the host and target syntaxes, etc.) and also because the dependency handling is done through an installer tool, similar to usual package managers. Check this email where the procedure is explained for a full GIMP build with crossroad, and install crossroad from pypi.

Building GIMP using Microsoft tools

Microsoft Visual Studio comes with its own C compiler. Most of GIMP development is done with the GCC and its MinGW Windows port.

Unfortunately both are not fully compatible, so integrating GCC into the Visual Studio build chain has its flaws, even while it might work in some points.

Because of this you are recommended to use MinGW for building GIMP on Windows.

Building GIMP plug-ins using Microsoft tools

How to build a GIMP plug-in with Visual Studio (archive.org link salvaged, original link, now broken, was: http://registry.gimp.org/node/24883)

Packaging third-party GIMP plug-ins for Windows

Users on the Windows and Mac OSX platforms expect software to be packaged in a self-installing file (an installer). Even though GIMP plugins (whether scripts in Python or Scheme, or executables in the C language) are relatively easy to install, you might want to package them using an installer such as Inno Setup.