Contents
How to guide for cross-compiling GTK+ for Win32
This is intended to be a quick-start guide for building GTK+ binaries for Win32, but from the comfort of Linux.
Bootstrap
To begin, you'll need to install mingw, the Linux/UNIX Win32 cross compiler. It allows you to build binaries for the Windows platform using a Linux box. Note you should also uninstall the Wine headers, because they cause nasty conficts with mingw's ones while compiling.
MinGW Installation instructions
Debian/Ubuntu |
Fedora/OpenSUSE |
Gentoo |
apt-get install mingw32 mingw32-binutils mingw32-runtime |
Follow the instructions on this page. |
emerge xmingw xmingw |
Wine headers Uninstallation
Debian/Ubuntu |
Fedora/OpenSUSE |
Gentoo |
apt-get remove wine-dev |
|
|
Building the sources using Jhbuild
First, follow the instructions to install Jhbuild, you may want to create a new user for this task to avoid conflict problems, instead of using the standard jhbuildrc file, which has the configuration options and variables for the building environment, you should grab this standard.jhbuildrc for Gtk+ cross compilation. Once you have downloaded it, log in as this new user and type:
cp standard.jhbuildrc ~/.jhbuildrc
Now you can start the build of gtk+ by typing:
~/bin/jhbuild build
Everything should be built and installed in ~/target, if you want another target directory, you should edit the jhbuildrc prefix value. For any comments on the jhbuild script and the moduleset, email me: aruiz at gnome dot org.
Building the sources from scratch
The easiest thing to do after this is to install the basic dependencies. I've made a tarball of these that you can grab from gtk-deps.tar.gz. You should extract them in /opt (they will extract into ./gtk so your build target is /opt/gtk).
mingw-configure
You'll need a mingw-configure script for building each package. Grab it here: mingw-configure
A note about optimizations: the mingw-configure attached does not include any -O optimization flags, so if you want to enable those you should edit the script. However, nasty bugs have been observed in very particular circumstances in gtk# applications when using these optimizations.
Next grab the latest glib, atk, cairo, pango, and gtk+ (either as tarballs or from svn). For each package, you'll need to copy the mingw-configure script into the root directory. Also, if you're pulling the sources out of Subversion instead of using tarballs, you will need to run ./autogen.sh before running ./mingw-configure for each package, because mingw-configure requires there to be a configure script.
Each time you call mingw-configure, you need to pass it a prefix where you would like to install the Win32 GTK. This should be somewhere that does not conflict with your system files (e.g., do NOT install it to /usr), and it probably should not be where your mingw runtime and compiler are installed. I use /opt/gtk but you can choose anywhere you want. The examples below say --prefix=$YOUR_PREFIX. You may either set an environment variable called YOUR_PREFIX=/opt/gtk or you may specify --prefix=/opt/gtk on each line.
Compiling GLib
When building GLib, you'll need to create a file called win32.cache that looks like this:
glib_cv_long_long_format=I64 glib_cv_stack_grows=no
- Copy win32.cache (shown above) into the base directory
- ./mingw-configure --enable-explicit-deps=no --cache-file=win32.cache --prefix=$YOUR_PREFIX
- make install
Compiling atk
- ./mingw-configure --enable-explicit-deps=no --prefix=$YOUR_PREFIX
- make install
Compiling cairo
- ./mingw-configure --enable-explicit-deps=no --with-x=no --enable-xlibs=no --enable-xlibs-xrender=no --prefix=$YOUR_PREFIX
- make install
Compiling pango
- ./mingw-configure --enable-explicit-deps=no --with-x=no --prefix=$YOUR_PREFIX
- make install
Compiling GTK+
- ./mingw-configure --enable-explicit-deps=no --disable-cups --prefix=$YOUR_PREFIX
- make install
Contact
If you have any problems or questions regarding this build process feel free to email me: bratsche at gnome dot org.
