MinGW32 Cross Compile

What you need

There are a few ways of setting up mingw32 cross compile on a GNU/Linux system (it is also be available for other systems like FreeBSD, NetBSD and Solaris, though the instructions here do not cover them, and the scripts here have not been tested on those platforms).
  1. Your distro might have a xmingw package you might be able to use:If you use this method, you can skip to the convenient scripts section.
  2. (not recommended) You could get the following binary:http://www.libsdl.org/extras/win32/cross/mingw32-linux-x86-glibc-2.2.tar.gz Which is a pre-built of option 3. Might be using an older version gcc and win32api headers (I've not tried this)
  3. Follow my step by step instructions below to build a recent version of MinGW32 (I'm no longer using this, but it should still work)
To build the cross compile system you need: You should be able to get these tools through your distribution's pakage manager. And you need to get my modified version of build-cross.sh (this was original found at http://www.libsdl.org/extras/win32/cross/build-cross.sh). If you are interested in doing this manually, please take a look at the script, it should not be too hard to follow.
Note that this build-cross.sh script does not build all gcc front-ends. It only builds the c and c++ compilers.

Step by Step Instructions

  1. put the downloaded build-cross.sh in a temporary directory with lots of free space.
  2. edit build-cross.sh with your favorite text file editor.
    1. un-comment or set PREFIX to the directory you want your MinGW32 cross tools to be installed in.
    2. un-comment or set SU or SUDO if you are installing into a directory that needs root/sudo access to write to it (you will be prompted for your root/user password when installing)
    3. pick your favorite downloader by uncommenting one of the lines starting with DOWNLOADER or set it to your command line download program
    4. set CFLAGS to optimisations that make sense for your platform, I'd recommend "-O3 -march=your_cpu", where your_cpu is the type of processor you are using.
    5. pick your favorite MinGW32/sourceforge mirror by setting MINGW_URL to a mingw mirror
    6. if you want, you could check to see if there are updated MinGW32 packages on this page. and update the version strings in the script.
  3. do the following at a shell in the directory you placed build-cross.sh:
    chmod +x build-cross.sh ./build-cross.sh
  4. The script will download, build and install the MinGW32 cross compile tools.

Convenient Scripts

There are two scripts which I find really convenient: mingw32-configure and mingw32-make, you can get them here: You will need to modify these scripts to point to where your cross tools are installed by changing the PREFIX and TARGET and HOST variables. If you used the build-cross.sh script, match the variables in your build-cross.sh script into these scripts. And put them in a directory somewhere in your PATH so that you can use them like any other command. mingw32-configure is used with autoconf generated configure script. mingw32-make on the other hand is use with Makefile, in place of make. If you decide that you do not want to use these scripts, I would recommend to at least take a look at what they actually do.

Other MinGW32 Cross Compile Instructions

There are other MinGW32 cross compile instructions found at:

I have never tried any of these instructions.