GIMP Musings

Downloads

Previous articles

So You Want to Compile Gimp

Building Gimp

Now that we have done the groundwork, we are ready to build Gimp. If you are not familiar with the groundwork, please read that article first. Then you can come back here and see how I did the compilation.

You have to build Gimp in this strict order. First you build BABL, then you build GEGL and then lastly you build GIMP in that order. We are going to build Gimp in the /opt/gimp-2.7.3 directory so that it will be easy to package and move around to various directories or even create an installer.

BABL

Download the git-master of babl - babl-git-master.tar.bz from the flamingtext website (see sidebar) in your src directory. I usually create a sub-directory called gimp-nightly-builds in the src directory and put the downloads there. Once you download, you unzip and change over to the babl-0.1.5 directory. Then you execute the following command for the Windows 32-bit version:

./configure --prefix=/opt/gimp-2.7.3 CPPFLAGS="-I/usr/include -I/c/Python27/include" LIBS="-L/usr/lib -L/c/Python27/Lib"

and for the Windows 64-bit version:

./configure --prefix=/opt/gimp-2.7.3 --build=x86_64-w64-mingw32 CPPFLAGS="-I/usr/include -I/c/Python27/include" LIBS="-L/usr/lib -L/c/Python27/Lib"

I always use the the build qualifier to be sure that it is in fact a 64-bit build.

Once configured, you make and make install as before. This will install BABL into /opt/gimp-2.7.3 directory.

GEGL

Download the git-master of gegl - gegl-git-master.tar.bz from the above website. Once you download, unzip and change over to the gegl-0.1.7 directory. Then execute the following command:

./configure --prefix=/opt/gimp-2.7.2 CPPFLAGS="-I/usr/include -I/c/Python27/include" LIBS="-L/usr/lib -L/c/Python27/Lib" --disable-docs

with the corresponding 64-bit --build qualifier as in compiling BABL. Once it is configured, run make and make install.

Libintl Issues (Windows 32-bit)

There are two issues with libintl - libintl_setlocale and libintl_printf (this will also be an issue compiling Gimp). This is because the mingw version of libint.dll.a does not have these variables defined. You can use the version that is available with GTK, but then I have noticed that you have a lot of errors compiling. So, now you have to undefine libintl_setlocale and redefine libintl_printf:

#if defined(setlocale) && defined(WIN32)
#undef setlocale
#endif

When I used this piece of code in gegl-int.c, it compiled. That is, at about line 434 add the above. You are going to need this code for compiling Gimp as well.

Gimp

Download the git-master gimp - gimp-git-master.tar.bz from the above site. Once downloaded, unzip and change over to the gimp-2.7.3 directory. Then you can execute the command for Window 32-bit:

./configure --prefix=/opt/gimp-2.7.2 CPPFLAGS="-I/usr/include -I/c/Python27/include" LIBS="-L/usr/lib -L/c/Python27/Lib"

and for Windows 64-bit:

./configure --prefix=/opt/gimp-2.7.2 --build=x86_64-w64-mingw32 CPPFLAGS="-I/usr/include -I/c/Python27/include" LIBS="-L/usr/lib -L/c/Python27/Lib" CFLAGS="-DMS_WIN64"

It is important to put the CFLAGS at the end, or you will not be able to get Python support. Here you are going to have to babysit for awhile. There are numerous places in the compilation process where you are likely to trip depending on whether you are running Windows 64-bit or 32-bit. There are more 32-bit trip points than there are 64-bit.

Python Support

For Python there is a wrinkle. Gimp configure looks for pygtk-codegen-2.0 which is deprecated. So, your Python pygtk-codegen-2.0 has to exist in the path for configure to find. Mine is located in the directory c:\Python27 and here is what it looks like:

#! /bin/sh

prefix=c:/Python27
exec_prefix=${prefix}
pygobject_script=${exec_prefix}/pygobject-codegen-2.0

echo "note: pygtk-codegen-2.0 is deprecated, use pygobject-codegen-2.0 instead" > /dev/stderr
echo "note: I will now try to invoke pygobject-codegen-2.0 in the same directory" > /dev/stderr

exec $pygobject_script "$@"

So you also need pygobject-codegen-2.0 in the same directory. Mine looks like:

#!/bin/sh

prefix=@prefix@
datarootdir=@datarootdir@
datadir=c:/Python27
codegendir=${datadir}/site-packages/gtk-2.0/codegen

PYTHONPATH=$codegendir
export PYTHONPATH

exec c:/Python27/python.exe c:/Python27/Lib/site-packages/gtk-2.0/codegen/codegen.py "$@"

Also, make sure to do this:

cd /c/python27/share/pygtk/2.0/defs $ cp gtk-base-types.defs gtk-types.defs $ cp gdk-base-types.defs gdk-types.defs

libtool looks for libintl.la, libintl.def, libintl.dll.a, and libintl.a in /usr/lib even though they are passed in during compilation through /opt/lib. The solution is to make a copy of these files in /usr/lib since Windows does not have ln -s.

Libintl revisited (Windows-32bit)

As mentioned above, libintl_setlocale and libintl_printf are going to be undefined based on the mingw version of libintl.dll.a. You will have to patch the source code with the libintl_setlocale undef as done above. You will have to modify gimp.c app.c and main.c and add the above to get rid of this error.

You will also find that libintl_printf is undefined. You will need to add this code

#define libintl_printf printf

in a number of files. I get this error in the files app/core/gimptagcache.c (line 599), plug-ins/file-sgi/sgi.c (line 456), plug-ins/common/animation-play.c (line 822), plug-ins/common/curve-bend.c (line 941 etc.), plug-ins/common/file-xwd.c (line 893 etc.), plug-ins/common/jigsaw.c (line 609 etc.), plug-ins/common/newprint.c and plug-ins/common/sample-colorize.c (line 2629). In all these files, just add the "#define" somewhere in the begining of these files.

Plug-ins.ico

The compile will stop with an error that plug-ins.ico is missing in the directory builds/windows. There is no such file in the source. So, I found a set of icons for ico files, renamed it plug-ins.ico and put it in the build/windows directory. The compile then proceed normally.

Next, while compiling I get the following error:

Creating library file: .libs/libgimpui-2.0.dll.a .libs/gimpui.o:gimpui.c:(.text+0x198): undefined reference to `gdk_win32_window_foreign_new_for_display' collect2: ld returned 1 exit status make[2]: *** [libgimpui-2.0.la] Error 1 make[2]: Leaving directory `/usr/src/gimp/gimp-2.7.2/nightly-builds/gimp-2.7.3/libgimp' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/src/gimp/gimp-2.7.2/nightly-builds/gimp-2.7.3' make: *** [all] Error 2

According to the developers, I am trying to compile against a too old version of gtk+-2.0 Well, my version is 2.24.4, so that can't be it unless my compilation of gtk+-2.0 somehow did not export gdk_win32_window_foreign_new_for_display. However, gdk_window_foreign_new_for_display is exported and so I changed this in two places: ./libgimp/gimpui.c (line 158) and ./app/widgets/gimpwidgets-utils.c (line 877)

TWAIN Issues

Another snag that has recently arisen is that twain does not compile. Why twain is not optional is beyond me. In any case, the issue seems to be that cairo and gdk-pixbuf headers are no longer found. The solution that worked for me was to add the respective headers directly into the Makefile in plug-ins/twain. So, modify line 83 (or thereabouts) of the Makefile and add the following at the end: -I/c/gtk/include/cairo -I/c/gtk/include/gdk-pixbuf-2.0. This seems to work and the compile moves ahead.

Little CMS Issues (Windows 32-bit)

Little CMS throws up a lot of errors during the build if you have lcms support. I found the problem to be the following. In the file display-filter-lcms.c, I commented out lines 22 onward as follows

/* #ifdef G_OS_WIN32 #define STRICT #include #define LCMS_WIN_TYPES_ALREADY_DEFINED #endif */

Uncomment only #include and then compilation will proceed without incident in the module directory.

That should be it. Now you should have gimp-2.7.3 compiled. Do make and make install and you are done.

If you wish to use the official version then Gimp 2.7.1 is available from here.

If you are inclined to leave a comment...

Your name:


Your email:


Your comments:


Return to Partha's home.