MinGW
Introduction
MinGW is a GNU-based toolset for
producing Windows applications.
Normally, MinGW is installed under Windows, and Windows is used as the
development environment.
However, it is possible to build a cross-compiler
version of MinGW, which uses Linux as the development environment. This
is what I have done.
Building the cross-compiler
Download the MinGW
build scripts from SourceForge, and unpack them:
su
- boxer
cd /usr/local/src
tar xf .../x86-mingw32-build-1.0-sh.tar.bz2
cd x86-mingw32-build-1.0
Edit the file x86-mingw32-build.sh.conf:
assume
DOWNLOAD_HOST
http://kent.dl.sourceforge.net/mingw
Execute the build script:
chmod
+x x86-mingw32-build.sh
./x86-mingw32-build.sh
Do
you wish to select components individually? (Default: NO)? NO
Please enter your preferred option: (Default: 1): 1
Would you like me to download any of these optional language packages?
(Default: YES)? YES
Do you require support for language `ada'? (Default: YES) NO
Do you require support for language `c++'? (Default: YES) YES
Do you require support for language `f77'? (Default: YES) NO
Do you require support for language `java'? (Default: YES) YES
Do you require support for language `objc'? (Default: YES) NO
Which directory should I use for the local package repository?
/tmp/packages/mingw-3.4.5
Please select one of the following mirrors (Default: 8): 8
Would you like to enable NLS for your cross compiler? (Default: NO)? NO
Would you like to use shared libraries available on this host?
(Default: YES)? YES
Do you wish to retain the standard setjmp/longjmp exception handler?
(Default: YES)? YES
Where should I install the cross-compiler, and its support tools?
/usr/local/opt/mingw32
Which directory should I use to create the build tree? (Default:
/home/boxer/tmp/mingw-3.4.5)?
Would you like me to delete all build files, when I'm done? (Default:
YES)? YES
Ok to commence building? (Default: YES)? YES
Build and install a Slackware package:
mkdir
-p /tmp/mingw32/usr/local/opt
mv /usr/local/opt/mingw32/ /tmp/mingw32/usr/local/opt
cd /tmp/mingw32
mkdir -p etc/profile.d
vim etc/profile.d/mingw32.sh
#!/bin/sh
export
MINGWROOT="/usr/local/opt/mingw32"
export
MANPATH="$MANPATH:$MINGWROOT/man"
export PATH="$PATH:$MINGWROOT/bin"
export
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$MINGWROOT/lib"
chmod +x etc/profile.d/mingw32.sh
mkdir install
vim install/slack-desc
su
makepkg /usr/local/packages/mingw32-3.4.5-i486-1fog.tgz
installpkg /usr/local/packages/mingw32-3.4.5-i486-1fog.tgz
Building applications
The C cross-compiler is called i386-mingw32-gcc.
A simple example of its use is:
i386-mingw32-gcc
-o hello.exe hello.c
The C++ compiler is called i386-mingw32-g++,
and other utilities in /usr/local/opt/mingw32/bin
are similarly named. See their respective man pages for information on
their use (and also the MinGW
wiki website).