Hi!
As part of my work to implement OpenCL in GEGL and GIMP, I have to compile it for Windows, and it’s no easy task. I’ll describe here the step-by-step how to build GEGL and GIMP from Git.
Maybe this post can help people trying to compile GIMP and help developers to improve GIMP building process in Windows.
Install MinGW and MSYS
First, use mingw-get-inst to install the latest MinGW and MSYS, choose to install C/C++ compilers and the basic development environment. Install them in the default path.
After that, open the mingw shell and install wget, openssl and unzip, so we can download things from the command-line:
$ mingw-get.exe install msys-wget $ mingw-get.exe install msys-openssl $ mingw-get.exe install msys-unzip
Installing Perl
Perl is used by many building scripts. Download and install ActivePerl.
Now, let’s create our build directory:
$ mkdir /opt
Copy the whole content of Active Perl folder to this new folder [C:\MinGW\msys\1.0\opt].
GTK+
Let’s create the folder where our GIMP will be:
$ mkdir /opt/gimp
Here the fun begins, we have to go to many places to find gtk+ precompiled binaries.
First, download from the GNOME ftp the GTK+ all-in-one bundle, it has many of the libraries we need.
$ cd /opt/gimp $ wget http://ftp.gnome.org/pub/GNOME/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.8-20111122_win32.zip $ unzip gtk+-bundle_2.24.8-20111122_win32.zip
But, ATK, GLib and GTK+ versions bundled are too old for the latest GIMP. So we get them from OpenSUSE repository:
$ cd /opt/gimp $ wget http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch/mingw32-atk-2.2.0-1.27.noarch.rpm $ wget http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch/mingw32-atk-devel-2.2.0-1.27.noarch.rpm $ wget http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch/mingw32-glib2-2.30.2-1.7.noarch.rpm $ wget http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch/mingw32-glib2-devel-2.30.2-1.7.noarch.rpm $ wget http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch/mingw32-gtk2-2.24.8-1.7.noarch.rpm $ wget http://download.opensuse.org/repositories/windows:/mingw:/win32/openSUSE_Factory/noarch/mingw32-gtk2-devel-2.24.8-1.7.noarch.rpm
No easy way to extract them in MSYS, so go to the directory and extract it using 7zip. Replace files when asked. EDIT: Remember to move /bin, /usr, etc in packages (e.g: opt\gimp\usr\i686-w64-mingw32\sys-root\mingw) to your build dir!
JPEG, TIFF and PNG
Download these packages from GNOME ftp and unzip them in /opt/gimp
$ wget http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/jpeg_8-1_win32.zip $ wget http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/jpeg-dev_8-1_win32.zip $ wget http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/libpng_1.4.3-1_win32.zip $ wget http://ftp.gnome.org/pub/GNOME/binaries/win32/dependencies/libpng-dev_1.4.3-1_win32.zip
Environment variables
Before compiling anything, set these variables:
export PATH=".:/opt/perl/bin:/opt/bin:/bin:/mingw/bin:c:/opt/gimp/bin" export PKG_CONFIG_PATH=/opt/gimp/lib/pkgconfig:/opt/lib/pkgconfig
Also, try to run gtk-demo to see if everything is ok:
$ gtk-demo.exe
A window should appear. If it complains about some dll missing, go to the GNOME ftp or the OpenSUSE repository, get it and install it in /opt/gimp.
Intltool
Get Intltool source and let’s install in /opt
$ cd /opt $ wget http://ftp.gnome.org/pub/GNOME/sources/intltool/0.40/intltool-0.40.6.tar.gz $ tar -xzvf intltool-0.40.6.tar.gz $ cd intltool-0.40.6 $ ./configure prefix=/opt $ make ; make install
Little CMS
Download lcms 1.19 source and move it to /opt/src.
$ tar -xzvf lcms-1.19.tar.gz $ cd lcms-1.19 $ ./configure --prefix=/opt/gimp $ make ; make install
Now, go to /opt/gimp/lib/pkgconfig. Here are all pkg-config files that will be needed to compile BABL, GEGL and GIMP. It’s very boring, but change all paths in them [prefix=] to /opt/gimp. You can use some script like:
find * -type f -name '*.pc' -exec sed -i "s#/devel/target/\(.*\)#/opt/gimp#g" {} \;
But change it to catch all pkg-config prefix formats in the folder.
BABL
Now you can get the latest packages directly from Git or from the nightly builds site.
$ cd /opt/src/babl-0.1.7
$ ./configure –prefix=/opt/gimp
$ make ; make install
GEGL
$ cd /opt/src/gegl-0.1.9 $ ./configure --prefix=/opt/gimp CPPFLAGS="-march=pentium -mtune=pentium" --disable-docs $ make ; make install
GIMP
Finally, GIMP! In this tutorial I didn’t enabled Python for simplicity. In http://git.gnome.org/browse/gimp/commit/?id=c15c3f4828527d9836de0ba168b4bfe00669cc21 I fixed some errors about undefined prototypes, so give a look if your source includes it.
$ cd /opt/src/gimp-2.7.5 $ ./configure --prefix=/opt/gimp CPPFLAGS="-march=pentium -mtune=pentium" --disable-python $ make $ make install
Now, there will be some errors probably:
- If you have an error about “Undefined GetUserDefaultUILanguage”, change line 50 in app/language.c:
//switch (GetUserDefaultUILanguage()) switch (GetUserDefaultLangID())
- I don’t know why, but my libintl doesn’t export some symbols like libintl_printf, so I had to put “#define libintl_printf printf” in the beginning of the following files:
- app/core/gimptagcache.c
- plug-ins/common/animation-play.c
- plug-ins/common/curve-bend.c:
- plug-ins/common/file-xwd.c
- plug-ins/common/jigsaw.c
- plug-ins/common/newsprint.c
- plug-ins/common/sample-colorize.c
- plug-ins/file-sgi/sgi.c
- if you have many errors with Little CMS, change lines 22-26 of modules/display-filter-lcms.c. Don’t really know why:
//#ifdef G_OS_WIN32 //#define STRICT #include <windows.h> //#define LCMS_WIN_TYPES_ALREADY_DEFINED //#endif
Now, go to /opt/gimp/bin and the gimp executable should be there. As we installed everything in /opt/gimp, just compress this folder if you want to create an installer or use it in another PC.
References
- http://partha.com/articles/groundwork.html
- http://partha.com/articles/buildinggimp.html
- http://gimpchat.com/viewtopic.php?f=7&t=3308&start=20
- http://gimpchat.com/viewtopic.php?f=7&t=3308&sid=e75252e1a95ce43ed6a2b364b1c95a30&start=30
- http://gimpchat.com/viewtopic.php?f=7&t=3308&sid=e75252e1a95ce43ed6a2b364b1c95a30&start=40
- http://www.gimpchat.com/viewtopic.php?f=4&t=3071&start=10



