MinGW is by Jan-Jaap van der Heijden
<J.J.vanderHeijden@student.utwente.nl>
Another explanation of how to use MinGW can be found
here,
by Cameron Donaldson. See also the Dev-C++ setup guide.
There are various tools tools to help you use
MinGW, including DialogBlocks
which can generate MinGW makefiles and compile your application.
MinGW vs Cygwin32
Basically, Cygwin32 does two things: it implements the PE-COFF format
for GCC and binutils, and it provides a transparent unix emulation layer
on top of Windows. This makes it possible to rebuild large, existing unix
applications with minimal changes to their source code, using GCC.
The flip side of the coin is a substantial decrease in speed for both
the compiler, and the applications built with it because of the
overhead introduced by the unix emulation layer (`cygwin.dll'')
MinGW-GCC reuses the Cygwin32 PE-COFF support code. But, it does not
attempt to be unix: it uses the Microsoft CRTDLL as it's C library.
So, MinGW-GCC, and the programs you build with it, behave like you would
expect from a Windows application. They supports drive letters for example.
A side effect of using CRTDLL is that MinGW is thread-safe, while Cygwin32
is not.
GCC vs EGCS
Quoting from the GCC 2.8 announcement:
``A new project, egcs (pronounced ``eggs''), is maintaining an
experimental version of the GNU C compiler. The egcs compiler
contains features that are candidates for inclusion in future versions
of GCC. The standard GCC distribution is intended to contain a mature
compiler that is stable and reliable; egcs aims at making experimental
changes available to interested users at an earlier stage in their
development process than would be appropriate for a production
compiler.''
The EGCS compiler has a number of features not found in regular GCC,
and the G77 Fortran compiler is included in the EGCS source tree.
It is up to you to decide whether you can't live without the bleeding edge
features, and want to risk bleeding edge compiler bugs....
An
EGCS port for MinGW exists and is maintained by Mumit Khan.
Project history
I started this project in July '97 out of personal frustration with
cygwin32. I didn't need the unix stuff, and thought that it was too slow
and cumbersome.
The
original MinGW project existed as a free set of replacement header
files for CRTDLL.DLL by Colin Peters, bolted on top of a cygwin32 compiler.
I then ported GCC and binutils themselves to MinGW, thus
eliminating all dependencies on cygwin.dll.
Over the past months (much to my surprise), MinGW-GCC has become an
accepted and widely used GCC port. All MinGW related changes have
been accepted by the FSF and merged back into the main GCC sources.
MinGW is here to stay!
Legal status
These tools are 100% free software. They come with no warranty. The GNU
components are covered by the
GNU General Public License, which guarantees your
freedom to modify and distribute the software. The MinGW replacement
headers for CRTDLL.DLL are in the public domain.
Installing the MinGW based tools
1. Get the software
Make sure you get at least the packages marked [required] from
the download page.
2. Unpack the software
Create a directory of your choice to install the software. I shall assume
`C:\MINGW32' but another location should be fine. Just make sure there are
no spaces in the name, e.g. not `C:\Program Files\mingw32'. GCC seems
to dislike spaces. From this directory, unzip the packages. Make sure you
have an `unzip' utility that understands long filenames.
3. Set environment variables
Edit your `C:\AUTOEXEC.BAT' and add `C:\MINGW32\BIN' to your PATH.
Also, add these entries:
set C_INCLUDE_PATH=C:\MINGW32\include
set CPLUS_INCLUDE_PATH=C:\MINGW32\include\g++;C:\MINGW32\include
set LIBRARY_PATH=C:\MINGW32\lib
set GCC_EXEC_PREFIX=C:\MINGW32\lib\gcc-
lib
If you install GNU bison, set these too:
set BISON_SIMPLE=C:\MINGW32\share\bison.simple
set BISON_HAIRY=C:\MINGW32\share\bison.hairy
If you installed in a directory other than `C:\MINGW32', you should change
these settings accordingly.
Mind the trailing slash in GCC_EXEC_PREFIX.
4. Test it
Now, try to run "gcc -v" from the command prompt.
It should respond with:
Reading specs from c:\mingw32\lib\gcc-lib\i386-mingw32\2.8.1\specs
gcc version 2.8.1
If it resonds differently, you may not have setup the environment correctly,
or another GCC may be present in your PATH.
5. Use it!
The compiler should work now. So, with your favorite editor, write a
small program:
#include <stdio.h>
int main(void)
{
printf("Hello, world!\n");
return 0;
}
Build it:
gcc hello.c -o hello.exe
Running `hello.exe' should present a familiar "Hello, world!" message.