Table of Contents
Moved from https://www.geany.org/Support/CrossCompile, unmodified. The information are heavily outdated and need to be adjusted for MSYS2.
Cross Compiling 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. The easiest way to get them is to use the GTK Bundle available on http://www.gtk.org/download-windows.html and http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libiconv-1.9.1.bin.woe32.zip.
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. Yura Siamashka wrote a nice script to do this at once, you can download it here: fix_pkgconfig.sh.
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 just 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 --enable-gnu-regex $ 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', you need another version of libiberty. Read again about Libiberty.
The option –enable-gnu-regex is necessary to use the bundled regular expression implementation which is necessary to be used on Windows.
For more information about the toolchain and some further information and what to take care about can be found on the following sites: http://ricardo.ecn.wfu.edu/%7Ecottrell/cross-gtk/#config-build and http://www.libsdl.org/extras/win32/cross/README.txt All needed files (wget-friendly) listed:
http://www.libsdl.org/extras/win32/cross/mingw32-linux-x86-glibc-2.5.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 http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.16/gtk+-bundle_2.16.1-20090419_win32.zip http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/libiconv-1.9.1.bin.woe32.zip