Install The Mingw Cross-Compiler
This is useful if you want to build windows executables on linux. See Cross-Compiling Under Linux.
The easy way: installing packages
On Debian, the packages you need are mingw32, mingw32-binutils and mingw32-runtime.
For SuSE, Redhat, Mandrake and other RPM-based installations, there are MinGW RPM packages. Note: As at 4 Oct 2007 the current MinGW Packages at this site don't contain a C++ compiler. I contacted the guy who packaged them and he said that building a c++ cross compiler was broken in the upstream sources at some point and the last version of his packages to contain a c++ compiler is Here. It should install and run on newer Fedora, even if it's compiled on Fedora 2.
For Gentoo, use the crossdev ebuild (ARCH should be whatever the host is running: x86, amd64, etc):
echo sys-devel/crossdev ~ARCH >>/etc/portage/package.keywords && emerge crossdev && crossdev i586-mingw32
The hard way: installing by hand
1. Download following packages
- binutils 2.3.19 source
- gcc3.2 source
- mingw-runtime-2.2 from SourceForge
- w32api-2.0 from SourceForge
2. Unpack sources somewhere (eg. /usr/src/crosscompiler )
3. Make a /usr/local/i386-mingw32 directory
4. Unpack mingw-runtime and w32api to this directory (these are neccessary header files)
5. Configure and compile binutils
./configure --prefix=/usr/local --target=i386-mingw32 make make install
6. Configure and compile gcc
./configure --prefix=/usr/local --target=i386-mingw32 Compile whole gcc package: make make install
or compile just c and c++ compiler (need less space) make LANGUAGES="c c++" make LANGUAGES="c c++" install
if you get a libtool error about libobjc, and you only compiled c and c++, make distclean, delete the offending unused compilers, and recompile: rm -rf libjava libobjc gcc/java gcc/objc
6.b Optional: you can strip binaries in /usr/local/bin and /usr/local/i386-mingw32/bin to make them smaller:
cd /usr/local/bin; strip i386* cd /usr/local/i386-mingw32/bin; strip *
At this point, you have a working cross-compiler.
7. Optional: compile mingw-runtime-2.2 and w32api-2.0
7.a Download sources:
*mingw-runtime-2.2 source from SourceForge *w32api-2.0 source from SourceForge
7.b. Configure and compile them
./configure --target=i386-mingw32 --prefix=/usr/local/i386-mingw32
Edit Makefile and change all compiler programs (gcc, ld, dlltool, ranlib, windres, ar, as, ld) to the
cross-compiler programs (i386-mingw32-gcc, i386-mingw32-ld, etc.)
make make install