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).
- Your distro might have a xmingw package you might
be
able to use:
- For Gentoo:
emerge
xmingw-runtime (I'm currently using this) - For
Ubuntu or Debian:
apt-get install mingw32
(I've not tested this) (for Ubuntu it's in Universe). - For
Suse or Fedora (Mandriva?): see http://mirzam.it.vu.nl/mingw/
(I've not tested this)
- Others...?
If
you use this method, you can skip to the convenient scripts
section. - (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)
- 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:
- bash shell enviroment (with
mkdir,
echo, test, su,
cp and what
nots) make (with
related tools like install, sed,
awk,...) - gcc compiler
for c/c++ (and related tools)
wget
(or curl, your favorite command line
downloader..)
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
- put the downloaded
build-cross.sh
in a temporary
directory with
lots of free space. - edit
build-cross.sh
with your favorite text file
editor. - un-comment or set
PREFIX
to the directory you
want your
MinGW32 cross tools to be installed in. - 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) - pick your favorite
downloader
by uncommenting one of the
lines starting with
DOWNLOADER or set it to
your command
line download
program - 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. - pick your favorite
MinGW32/sourceforge mirror by setting
MINGW_URL
to a mingw mirror - 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.
- do the
following at a shell in the directory you placed
build-cross.sh:
chmod +x build-cross.sh ./build-cross.sh
- 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.