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.
- 1 Building GIMP natively under Windows using MinGW
- 2 Cross-Compiling GIMP under UNIX using MinGW-w64
- 3 Building GIMP using Microsoft tools
- 4 Building GIMP plug-ins using Microsoft tools
- 5 Packaging third-party GIMP plug-ins for Windows
Building GIMP natively under Windows using MinGW
MinGW is an open source Linux environment available on the Windows platform.
Partha discusses building GIMP on and for the Windows platform using MinGW.
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: Ubuntu 12.04LST and Mageia 2 distribution.
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
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.
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
Chose your target. For building Windows 64 bits executable for instance:
$ export HOST=x86_64-w64-mingw32
For 32 bits:
$ export HOST=i686-w64-mingw32
Create a dependencies prefix:
$ export DEP_PREFIX=$HOME/w64/usr/$HOST/sys-root/mingw/
And an installation prefix, that you chose earlier:
$ export PREFIX=$HOME/w64
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
Used tools though may still use the old path as well, but preferably the downloaded MinGW:
$ export PATH=$PREFIX/bin:$DEP_PREFIX/bin:$PATH
NOTE: this step is useless if you installed MinGW-w64 from your distribution.
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 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".
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.
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 install
$ cd ..
$ git clone git://git.gnome.org/gegl
$ cd gegl
$ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no --disable-docs
$ make install
Though not in the original email, I had to compile liblzma as well. Probably it depends on the options you set on GIMP's configure. In my case xz-5.0.4 worked well.
$ cd ..
$ 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 install
$ cd ..
$ git clone git://git.gnome.org/gimp
$ cd gimp
$ ./autogen.sh --prefix=$PREFIX --host=$HOST --enable-introspection=no --disable-docs --without-libjpeg --disable-python --without-xmc
$ 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.
Building GIMP using Microsoft tools
Building GIMP plug-ins using Microsoft tools
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.