Setting up a cross compiler on Linux to build Geany for Windows
Getting the files
You need the following files:
First the compiler with all related tools(binutils, linker, ...). Visit http://www.libsdl.org/extras/win32/cross/ there are precompiled binaries for x86 Linux available and also a script to compile all by hand. I used the precompiled binaries to save time. Then download cross-make.sh and cross-configure.sh from the same site. There is also a ReadMe file, which has more information.
To compile some code which uses the Windows API, you need the appropriate header files. These can be obtained from:
http://prdownloads.sourceforge.net/mingw/w32api-3.1.tar.gz?download
Furthermore, you need some libraries and their include files for the GTK environment:
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/atk-1.9.0.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/atk-dev-1.9.0.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/glib-2.6.6.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/glib-dev-2.6.6.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/gtk+-2.6.10-20050823.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/gtk+-dev-2.6.10-20050823.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/pango-1.8.2.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/pango-dev-1.8.2.zip
ftp://ftp.gtk.org/pub/gtk/v2.8/win32/dependencies/gettext-0.14.5.zip
ftp://ftp.gtk.org/pub/gtk/v2.8/win32/dependencies/gettext-dev-0.14.5.zip
ftp://ftp.gtk.org/pub/gtk/v2.8/win32/dependencies/libiconv-1.9.1.bin.woe32.zip
I chosed the latest 2.6 series of GTK because for Windows Me or older only a GTK 2.6 runtime environment is available and we want to support them. If not, just use a newer GTK version.
Libiberty
And don't forget to get a newer version of libiberty. The one included in the binary archive is missing some symbols which are needed. A working version can be found here: http://files.uvena.de/misc/libiberty.a.gz (note that this file is also from the mingw32 project). Probably, you won't need this file if you are compile the compiler and related tools by hand.
Unpacking the files
Now, after downloading the files, they have to be extracted. Start with the precompiled binaries. Extract them somewhere to your filesystem, I recommend /usr/local/cross-tools, then you have not much work with adjusting paths.
/usr/local/cross-tools is now the PREFIX and all other files should be extracted into this directory. So, proceed with the other archives and extract them into your prefix.
After that, copy the both scripts cross-configure.sh and cross-make.sh somewhere in your path. Perhaps, it is a good idea to rename them to something shorter. On my system the scripts are called xconfigure and xmake and reside in ~/bin.
The file libiberty.a.gz has to be extracted to PREFIX/lib/.
Setting up the environment
First, go to PREFIX/lib/pkgconfig/ and edit all .pc files. They have a line prefix= which you have to edit and set it to your prefix, in my case /usr/local/cross-tools/. Do this for every .pc file or write a little script which does this automatically ;-).
Then edit the script cross-configure.sh. Add the following lines somewhere at the beginning of the file:
PKG_CONFIG_PATH=/usr/local/cross-tools/lib/pkgconfig/
export PKG_CONFIG_PATH
Don't forget to adjust your paths. The other script doesn't have to be modified.
Configuring and compiling your sources
You have done the job. If all went well, you can start compiling your sources.
For configuring and compiling you should use the two scripts. cross-configure.sh can be used like the usual ./configure command. The cross-make.sh is a simple wrapper for the make command.
Let's say you want to compile Geany, the following should work(assuming cross-make.sh and cross-configure.sh are in your PATH):
$ svn co https://svn.sourceforge.net/svnroot/geany/trunk/ geany
$ cd geany
$ ./autogen.sh
$ cross-configure.sh
$ cross-make.sh
After that, you should have an executable in the src directory named geany.exe.
If you got some linker errors like undefined reference to `_fnmatch' or undefined reference to `_lrealpath', you need another version of libiberty. Read again the beginning of this text.
Problems
If you all do like described above and all worked fine, your executable won't be able to use gettext translation catalogs. I don't know yet why it doesn't work. If someone knows it, please drop me a mail.
All needed files (wget-friendly) listed:
http://www.libsdl.org/extras/win32/cross/mingw32-linux-x86-glibc-2.3.tar.gz
http://www.libsdl.org/extras/win32/cross/cross-make.sh
http://www.libsdl.org/extras/win32/cross/cross-configure.sh
http://prdownloads.sourceforge.net/mingw/w32api-3.1.tar.gz?download
http://files.uvena.de/misc/libiberty.a.gz
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/atk-1.9.0.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/atk-dev-1.9.0.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/glib-2.6.6.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/glib-dev-2.6.6.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/gtk+-2.6.10-20050823.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/gtk+-dev-2.6.10-20050823.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/pango-1.8.2.zip
ftp://ftp.gtk.org/pub/gtk/v2.6/win32/pango-dev-1.8.2.zip
ftp://ftp.gtk.org/pub/gtk/v2.8/win32/dependencies/gettext-0.14.5.zip
ftp://ftp.gtk.org/pub/gtk/v2.8/win32/dependencies/gettext-dev-0.14.5.zip
ftp://ftp.gtk.org/pub/gtk/v2.8/win32/dependencies/libiconv-1.9.1.bin.woe32.zip