If you have any further questions, please refer them to the
MinGW mailing list.
This page is updated by the MinGW Developers as time permits. The
Q&A provided here were obtained from the MinGW mailing list,
its members, various MinGW related web sites and experience. We would like to
thank all who have contributed to this FAQ.
- What is mingw?
- Copyright issues
- msvcrt vs crtdll?
- Where to get mingw
- Using older versions
- How to install
- Mailing list
- Other compiler distributions
- Help
- Runtime libraries
- Debugging
- IDEs and editors
- Using mingw as a cross-compiler
- Compiling and building
- More compiling and building issues
- Compiler output
- COM support
- Make programs
- Patches
- GUIs/application frameworks/user interfaces
- Libraries
- Other programming tools
- How/where to report bugs
- Other resources
-
What is MinGW?
MinGW is a compiler system based on the GNU GCC and Binutils projects
that compiles and links code to be run on Win32 (Windows) systems. It
provides C, C++ and Fortran compilers plus other related tools.
'MinGW' refers to the "Minimalist GNU for Windows" project. If you
see references to mingw32 instead of mingw, they are referring to
the same compiler system. The project's name change from mingw32 to mingw is
to prevent the implication that mingw will only works on 32 bit systems.
As 64 and higher bit machines become more common, mingw will evolve
to work with them. The project was originally started by
Colin Peters, was taken over by Mumit Khan and is now maintained by
a group of developers through the Sourceforge web
site. Mingw uses the Microsoft runtime libraries, distributed with the Windows
operating system. Unlike other ports of gcc to Windows, the
runtime libraries are not distributed using Gnu's
General Public License. You, therefore, do not have to distribute
your source code with your programs.
Back to index
Mingw executables
Gcc distributions such as mingw provide a gcc executable
which can be used to compile files in any language the distribution
supports. They also provide other compiler drivers, which in the
case of mingw are executables such as g++, c++, g77, etc.
These drivers invoke the appropriate compiler programs
to compile your source code. Note that g++ and c++ are identical
files except for the name difference. This is for historical purposes
and allows backward compatibility with Unix compiler distributions which
link c++ to g++. While you can compile and link different language files through
the gcc program and the various other compiler drivers, it's
recommended that you use the appropriate driver for the language you're
working with. That way, determining what language specific libraries
are needed and other language specific issues are all handled for you by
the driver. The g++ and c++ executables are for C++, the g77 executable is for
FORTRAN and the gcc executable is for C.
Along with the compiler drivers, you'll find other tools in your
bin directory. This includes cpp, a preprocessor which handles
directives such as #include and #define .
You'll also find windres, which is responsible for compiling Windows
resource files into a usable format. The executables dlltool and
dllwrap are programs used in creating and working with dlls (dynamic
link libraries). The executable ar (i.e. archiver) lets you create
and work with static libraries. The executable gdb is the Gnu
debugger. Other executables are in this directory as well. For more
information on these programs, see the Gnu documentation in the
Help section.
Back to index
Copyright issues
Various licenses come with Open Software. Some Open Software
code requires you to redistribute your own source code
when you add their code to your programs. Some source code is public
domain and you can do whatever you like with it, including sell
your own program which makes use of it. One of the nice features
of mingw is that you can do whatever you wish with the programs you
create using it and you are not required to distribute your own
source code. You'll need a legal copy of crtdll.dll or msvcrt.dll on
the Windows system the program will run on, but most Windows
operating systems have one or both supplied with the operating
system and they may be available from the Microsoft web site.
For those interested in the actual legal details and technical
points regarding copyright of the mingw compiler system, copyright
information is included in the headers and the source files of the
compiler distribution package.
The following also applies:
- The mingw basic runtime system, which is basically the glue
to the underlying operating system, is completely in the public
domain. The runtime system includes mingw headers (such as stdio.h),
libraries (such as libmingw32.a) and import libraries for
CRTDLL/MSVCRT.
- W32API, which consists of the headers and import libraries related to
WIN32 API access, is released under
copyright. The copyright agreement states no restrictions are
placed on programs or object files compiled with the library. There are
restrictions if you wish to distribute the library as part of another
package.
- Mingw development tools, which include compilers, linkers, other
tools in the bin directory, etc., are released under the
GNU General Public License.
- Profiled code, which is code compiled and linked with the
-pg option for runtime
profiling, also falls under the GNU General Public License.
Here are some further reference sources for the various
licenses that apply to pieces of the mingw distribution:
Back to index
msvcrt vs crtdll?
Mingw requires the Microsoft runtime libraries. You'll need
either crtdll.dll or msvcrt.dll on a system in order to run a
program. There are two distributions of mingw, one for each
runtime library option. Use the version of mingw for the type
of runtime library you wish to work with. Which is better? That
depends on what you need. Crtdll is on all Win32 systems, but is
no longer updated. It is available on platforms such as Windows
3.11/Windows NT 3.5 and platforms that use Win32s. Msvcrt is not
guaranteed to be on every Windows operating system, but it is more
up-to-date and may offer more features. It handles threading better
than crtdll and supplies functions such as _i64toa and _atoi64
that crtdll doesn't. There is a possibility that crtdll may not
be supported in future releases of mingw.
Back to index
Where to get mingw?
You can download mingw from
http://www.mingw.org
Back to index
Using older versions?
It's highly recommended that you use the latest version of
mingw. There are older versions available on the Internet or
through books and CDs. Older versions may have more bugs and can
be more difficult to install or use than the latest version.
Please be sure that you have downloaded and are working with the
latest version, especially if you are having any difficulties with
installation or use. If you are not sure of your version, you can
type gcc -dumpversion to find out what you are
using. The current version is 2.95.2.
Back to index
How to install?
To install mingw, choose the distribution you want, either
mingw using crtdll.dll or mingw using mscvrt.dll. Download
the distribution. Unzip it. (Zip/unzip utilities are available
from
ftp://ftp.freesoftware.com/pub/infozip/.)
If the bin directory that holds mingw executables isn't already
in your path, add it. That's it.
If you need help setting your path, try the following.
On Windows NT, select Start/Settings/Control Panel/System/Environment
and edit your path. For Windows 95/98, edit your autoexec.bat file.
If you already have a line that starts with PATH or SET PATH, add the
mingw bin directory to your list or you can add the
following after the line that sets your path in autoexec.bat:
SET PATH=C:\mingw32\bin;%PATH%
Substitute the directory your mingw binaries (such as gcc.exe)
are located in for C:\mingw32\bin. If your autoexec.bat file runs any
other batch files at the end of it, be sure to place the lines to
change your path before calling another batch file. For example,
my autoexec.bat file has a line that runs a batch file to change the
screen color when it's done setting everything else. When I place path
changes after the batch file call, the path never gets updated. This
is only a problem with calling other batch files (files with .bat extension).
You can run programs like doskey from your autoexec.bat with no problem.
Back to index
Coexisting with djgpp
Mingw can be installed and run when other compilers are on
your machine.
The important thing is that mingw needs to be
able to find its executables in the file path. If you mix djgpp
file paths with mingw file paths, you can have problems when
your system tries to find the appropriate executables. If you
must have both compilers' locations in your path, make sure the
proper one comes first in the list. The safest situation is to
only have the compiler you're working with listed in your current
path. One solution djgpp users have found that lets them run both
compilers is to create two batch files, one for each compiler. Set
up correct paths and other environment variables in each batch
file. Run the appropriate batch file before doing any compiling.
Another solution is to create a link in Windows that will open up
a DOS box and set the appropriate environment variables for each
compiler through Windows.
Back to index
Mailing list
There is a mailing list for mingw. You can join or find out
more about it from
http://lists.sourceforge.net/mailman/listinfo/mingw-users.
The list covers announcements, information regarding compilation of various
libraries using mingw, discussion of problems and work-arounds and
other mingw related topics.
-
The mingw32 mailing list archives are open to anyone, subscribers and
non-subscribers alike. You can now post messages to the list even if
you are not a subscriber.
-
Just a reminder... Developers on this list all have their favorite
tools, libraries and operating systems. Please be tolerant of other developers
who don't necessarily want to work with your favorites. Thank you.
Back to index
Other compiler distributions
Other compiler packages are available for Win32 systems. These
include:
- lcc-win from
http://www.cs.virginia.edu/~lcc-win32/ is a Win32 C
compiler complete with integrated environment. I believe the
distribution includes a working GUI resource editor that has been
reported to work with other compilers such as mingw.
- bloodshed Dev-C++ from
http://www.bloodshed.net/devcpp.html is a distribution of mingw32 with
an IDE and other integrated tools.
- rsxnt, rsxntdj from
http://www.mathematik.uni-bielefeld.de/~rainer/
is used in conjunction with Gnu compilers on various platforms such
as djgpp and emx to create Win32 executables.
- Watcom from
http://www.openwatcom.org/ is a collection of multi-platform C/C++ and
Fortran compilers with integerated development environments. Sybase
has recently agreed to release the Watcom compiler under an Open Source
License under the management of SciTech Software Inc.
Their plans are to work with other Open Source development groups
once development of the new Open Source version commences.
Check their web site for the latest news on Watcom development.
Back to index
Help
Compiler, Win32 and C functions help files
The following are URLs of sources for compiler, Win32, C++ or C function
documentation available freely through the Internet.
If you know of any other documentation, please mention it
so it can be added to the list.
Tutorials
OpenGL Tutorials:
Database Tutorials:
- ODBC Oracle Example Program,
ftp://ftp.simtel.net/pub/simtelnet/win95/prog/odbcora8.zip
An example of how to write ODBC code. The Visual C++ version
compiles with the mingw32 C compiler (although main really should be
declared with a return value of int for mingw to be happy). When creating
the executable, be sure to link in -lodbc32 .
C++ Tutorials:
Back to index
Runtime Libraries
The gcc compiler series has been built successfully with many different
runtime libraries. Mingw provides two different runtime library options,
crtdll.dll and msvcrt.dll. See the msvcrt vs crtdll? section for more information.
Both crtdll.dll and msvcrt.dll are available on most, if not all, Windows operating
systems. The Cygnus gcc distribution uses the Cygnus runtime library which is
available under the GNU General Public License.
Similarly, the U/Win gcc distribution uses its own runtime library which is also
available under the GNU General Public License. The main problem with using
GPL'd runtime libraries is that all source must be distributed with the executables
created by the compiler. When crtdll.dll or msvcrt.dll are used as runtime libraries
this is not an issue.
Other runtime libraries are usable with mingw/gcc. One such library in the works
is PW32, the Posix-over-Win32 layer. It provides a subset of POSIX and UNIX functions.
The Watcom runtime library source is now available for download from Sybase's web site
on their download page. Another option might be to combine mingw with
the Watcom runtime library.
To find out more about PW32, try it out or volunteer to help, see
http://pw32.sourceforge.net/
If anyone manages to use mingw with the Watcom runtime library, please
let me know so I can add details to the FAQ.
Back to index
Debugging
Write statements
The simplest method of debugging is to add write statements to
the code in order to tell what's going on. In C, puts and printf
are useful. In C++, cout is helpful. In Windows, the MessageBox
is helpful as long as you don't call it during a paint routine. If
you do anything in a Windows application that tries to repaint the screen during a paint
call, you can get stuck in an infinite loop. Some programmers find using assert
statements a good method to help debug.
Map files and crash addresses
If you can get the address of a program crash and you have a map
file for your program, you can locate the line or routine where the program crashed.
Certain systems, such as Windows NT and some Windows 98 machines, have
a program named Dr. Watson available which will supply information about
a program when it crashes. Some commercial compilers also supply a program
with this functionality. If you have one of these programs available on
your system, you can use the address of the crash supplied by it to
help locate the problem. If anyone knows of any freeware programs that duplicate
this functionality or has source code to find the address during a
crash, please let me know.
Here are three ways to create a map file. Choose the method
you like best. In these examples, I've used sample names
such as file.map and file.exe. Change the map, executable and object
files to ones more relevant to your particular project.
ld file.exe -Map file.map
nm --extern-only --defined-only -v --print-file-name file.exe > file.map
g++ -Wl,-Map,file.map -o file file.o otherfile.o
On systems such as Windows NT, you can specify what application is run
when a program crashes. To do so, edit the Debugger value for the
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug
registry key and change it to the program you want run after a crash.
Windows makes available the ID of the process to debug and
an event ID to signal when the debugger finishes calling
DebugActiveProcess. These can be passed via command line to the program
listed as Debugger. Setting the auto value for this registry key
to 1 causes the program listed as Debugger to automatically run.
Setting it to 0 brings up a crash dialog instead.
Dr. MinGW
Dr. MinGW is a just-in-time exception handler for mingw.
See
http://www.fe.up.pt/~em96115/gnu-win32/ for a copy.
It will automatically install itself as the default debugger in
the registry if run with the proper options. If you do not
already have some debugger installed on your system, you may
have to add HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AeDebug
to your registry by hand before successfully running the install option.
Debugger
For more in depth debugging, you will most likely need the help
of a debugger program. Mingw includes gdb (Gnu debugger) in its
distribution.
GUI debugger
Many people prefer a GUI front end to their debugger. Mingw
currently does not supply this in its distribution. This leaves
two options for GUI debuggers. Use one from another compiler distribution
or use a GUI front end to gdb. Here are some links for both options.
These are some GUI front ends to gdb:
Check the
Other compiler distributions
section for other compilers with different debuggers.
Back to index
IDEs and editors
What IDEs are available?
There are several IDEs (Integrated Development Environments)
for Win32 platforms. Some are freeware and some are not. Some
are specifically tailored to mingw and others are for more
general use.
- RSXIDE,
http://www.mathematik.uni-bielefeld.de/~rainer/
Built in support for djgpp, rsxnt, emx/nt09d and mingw. Works with
any editor that supports DDE. This program in conjunction with an editor
like PFE makes an easy-to-use but flexible IDE.
- DFE95,
http://www.musc.edu/~brannanp/dfe95/
Works with mingw.
- Vide, http://www.objectcentral.com
Tested with mingw.
- Quincy 2000, http://www.midifitz.com/alstevens/quincy2000
From Al Stevens. Covered in various Dr. Dobb's articles and Al
Stevens books on learning C++. The Quincy 99 version had a bug when running
on Windows NT. Don't know if this has been corrected in the latest version.
- JFE (Jen's File Editor),
http://cs-alb-pc3.massey.ac.nz/software/
For use with mingw. The source is available in the file jfesrc.zip, but
appears to be written to compile using the Microsoft compiler. The IDE is
available in gcc.exe along with a small gcc distribution. Has some nice features
including automatically building HTML documentation files for projects and easy
viewing of and navigation to functions in a project. (I personally miss the key-mapping
functionality of PFE though.)
- Code Magic,
http://www.codemagiccd.com/
- Super IDE,
http://protostar.hypermart.net/
- Pow! - Programmers Open Workbench,
http://www.fim.uni-linz.ac.at/pow/Pow.htm
- ACIDE,
http://pages.zoom.co.uk/andyc/
Can be configured to work with many languages/compilers.
- Visual Programming Armoury,
http://www.zdnet.co.uk/software/free/dev/java/sw49.html
- Assembler Laboratory, http://tihlde.org/~kurtg/
- Octopod, http://www.octopod.net
Commercial IDE.
What editors are available?
Other reference sites
- Free Editors for C/C++ Programming with Windows at
http://www.blockdev.net/Community/Editors/
lists other editor and IDE resources.
- For those who prefer DOS editors, there are many good options such as edwin and pedit.
Back to index
Using mingw as a cross-compiler
See
http://www.nanotech.wisc.edu/~khan/software/gnu-win32/mingw-cross-howto.txt
for definitive information regarding cross-compilers.
Linux cross-compiler information, C/C++ binaries for Linux, plus links to various multimedia libraries
are also available from
http://www.devolution.com/~slouken/SDL/Xmingw32/.
Thanks to Carl-Michael Kleffner for recommending this link.
Back to index
Compiling and Building
How to create a console application
Here's an example. The following is a code sample for a simple
C program. Cut and paste it into a file named hello.c to try it out.
#include <stdio.h>
int main(int argc, char **argv)
{
printf ("Hello\n");
return (0);
}
If you want to create a console mode executable hello.exe
from a c file called hello.c, try the following:
gcc -c hello.c
This compiles hello.c into an object file, hello.o
gcc -o hello hello.o
This creates an executable hello.exe from hello.o
Alternatively, you can compile and link in one step using:
gcc -o hello hello.c
The following is a code sample for a simple
C++ program. Cut and paste it into a file named hello.cpp to try it out.
#include <iostream>
int main(int argc, char **argv)
{
cout << "Hello" << endl;
return (0);
}
For the C++ program, use the following to compile and link:
g++ -c hello.cpp
g++ -o hello hello.o
How to create a windows application?
Here's an example. The following is a code sample for a simple
Windows program. Cut and paste it into a file named hello.c to try it out.
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
MessageBox (NULL, "Hello", "Hello Demo", MB_OK);
return (0);
}
If you want to create a Windows executable hello.exe,
from a c file called hello.c, try the following:
gcc -c hello.c
This compiles hello.c into an object file, hello.o
gcc -o hello hello.o -mwindows
This creates an executable hello.exe from hello.o
The -mwindows switch is needed to create Windows executables
instead of console applications. It assures the appropriate Windows libraries
are linked in for you.
To get a console screen along with a standard windows application, add
the -mconsole flag as well as -mwindows .
If you have resources from a resource file (.rc) that also need
to be added to your executable, you'll need to compile the resource
file as well as your other source files and include the compiled resources
when linking to create the executable. Here's an example that shows how to
compile and link in a resource file named resfile.rc.
windres -o resfile.o resfile.rc
gcc -o hello hello.o resfile.o -mwindows
How to create a dll
Here's an example. Cut and paste the following into a file
named dllfct.h:
#ifdef BUILD_DLL
// the dll exports
#define EXPORT __declspec(dllexport)
#else
// the exe imports
#define EXPORT __declspec(dllimport)
#endif
// function to be imported/exported
EXPORT void tstfunc (void);
Cut and paste the following into a file named dllfct.c:
#include <stdio.h>
#include "dllfct.h"
EXPORT void tstfunc (void)
{
printf ("Hello\n");
}
Cut and paste the following into a file named hello.c:
#include "dllfct.h"
int main ()
{
tstfunc ();
return (0);
}
To create the dll and an executable that uses it, try the following:
gcc -c hello.c
gcc -c -DBUILD_DLL dllfct.c
dllwrap --output-lib=libtstdll.a --dllname=tst.dll --driver-name=gcc dllfct.o
gcc -o hello.exe hello.o -L./ -ltstdll
For more information on dlls, see
http://www.nanotech.wisc.edu/~khan/software/gnu-win32/dllhelpers.html
How to create a def file for a dll
There are several methods that can be tried in order to create a definition file
(.def) when one is not supplied.
Back to index
More compiling and building issues
main or WinMain?
Windows programs use WinMain instead of main. However,
mingw is set up so that you can use either.
Why are my executable sizes large?
Some users on the mingw32 mailing list have noticed
ending up with unusually large executable sizes. This can happen
if you leave in debugging information. To make your executables
smaller, try linking with the -s switch or use the strip program
on the final executable (not the object or library files). Compiling
without the -g option is another alternative.
Linking to other compilers' libraries
Due to binary compatibility issues between different compilers, you cannot
directly link in libraries or object code from one compiler to another compiler such
as mingw and expect it to work. The reverse is true as well. Even dlls are not
completely portable across compilers. To deal with this issue, various
standards such as COM and CORBA were created.
If you want to use a library or objects from one compiler with another,
the easiest way to do it is to have the source (.c, .cpp, .rc, .def, etc.) and
to compile and build that code with the desired compiler and its tools. You can use
the same dll with different compilers with varying degrees of success. You'll need either
a .def file or to use calls such as LoadLibrary/GetProcAddress to do so. The self-hosting
version of mingw32 provides better support of Visual C++ binary compatibility. You can use
certain libraries built with Visual C++ with this version of mingw32 without having to rebuild them
using mingw and vice versa.
Linking libraries
If you place libraries before the object files that reference them,
the linker will be unable to find them. The linker works left-to-right,
single pass. The easiest way to avoid the problem is to place all libraries
after the object files. It is also recommended that libraries to be linked
with should not be repeated on the command line. While listing the same library
more than once works with several linkers, the mingw linker currently has problems
with this situation and may leave needed routines out of the link when this is done.
Here's an example of a line that links in multiple objects and libraries:
gcc -o hello hello.o util.o pdcurses.a -ltstdll
The command links in the libraries pdcurses.a and libtstdll.a to create
an executable hello.exe.
Linking to dlls
Although dlls are supposed to be fairly portable across different Windows compilers,
accessing dlls through a library file (.lib or .a) is not. The library
file formats are specific to particular compilers and cannot be used
portably with different compilers unless the compiler provides support
for it.
There are two ways to link to a dll.
- Provide a library file to let the program know what routines are
in the dll and where to find them.
- Use LoadLibrary/FreeLibrary and GetProcAddress.
In order to use Microsoft or other compiler dlls, you can use any
of the following methods:
(Note: While C functions in dlls are generally portable across compilers,
I'm told that this isn't necessarily true for C++. When writing your
own dlls, you can mark C++ functions and data in dlls as extern "C" to
help bridge some of the C++ portability issues between compilers. See
the mingw32 mailing list archives for more portability concerns regarding dlls.)
What are other useful compiler flags?
You can get help by using the --help option.
For example:
gcc --help
You can display the compiler version using the -dumpversion option.
You can display the platform using the -dumpmachine option.
You can specify include files not in your path by using -I .
For example:
gcc -c hello.c -I../pdcurses
You can specify a directory for library files indicated by the -l
option by using -L .
You can use -g to add debug information for the debugger to work
properly.
You can use -D to specify a define.
For example:
gcc -c hello.c -D__WINDOWS__
You can use -v to find out more about the executables being
invoked.
For example:
gcc -v
Back to index
Compiler output
Error redirection
Mingw displays compilation and linking errors to stderr instead
of stdout. To easily view these errors, you may need to redirect
the output to stdout or a file. Some methods to do so include using
one of the following programs:
Keeping the dos box open
Some users have had trouble with the dos box closing after
building a program and haven't been able to see their errors. The
mingw32 mailing list came up with several suggestions on how to
deal with this. One suggestion from Franco Bez is as follows:
By modifying a few Registry Keys - you can add a context menu item
Run - stay open , so you simply right click on
the Batch file and choose Run - stay open and your batch
runs and stays open.
The following Registry files do this and a little more:
- context menu
DOS Box for Folders and files - opens a dos box in the folder
- context menu
Notepad for all files, even those with missing/unknown
extension - opens the file in Notepad for editing
- context menu
Run - stay open for bat, com and exe files
Place the following lines in a file (such as Win95_98.reg or WinNT.reg) and
simply merge the file for your system to your registry by doubleclicking it.
The example below is for Windows NT. If you are using a Windows 95 or 98
system, change all the occurrences of cmd to command.com .
REGEDIT4
[HKEY_CLASSES_ROOT\*]
[HKEY_CLASSES_ROOT\*\shell]
[HKEY_CLASSES_ROOT\*\shell\dos_box]
@="DOS Box"
[HKEY_CLASSES_ROOT\*\shell\dos_box\command]
@="cmd"
[HKEY_CLASSES_ROOT\*\shell\open]
@="Notepad"
[HKEY_CLASSES_ROOT\*\shell\open\command]
@="Notepad.exe %1"
[HKEY_CLASSES_ROOT\Folder\shell]
[HKEY_CLASSES_ROOT\Folder\shell\dos_box]
@="DOS Box"
[HKEY_CLASSES_ROOT\Folder\shell\dos_box\command]
@="cmd /k cd %1"
[HKEY_CLASSES_ROOT\batfile\shell]
[HKEY_CLASSES_ROOT\batfile\shell\runstayopen]
@="R&un - Stay open"
[HKEY_CLASSES_ROOT\batfile\shell\runstayopen\command]
@="cmd /k %1"
[HKEY_CLASSES_ROOT\comfile\shell]
[HKEY_CLASSES_ROOT\comfile\shell\runstayopen]
@="R&un - Stay open"
[HKEY_CLASSES_ROOT\comfile\shell\runstayopen\command]
@="cmd /k %1"
[HKEY_CLASSES_ROOT\exefile\shell]
[HKEY_CLASSES_ROOT\exefile\shell\runstayopen]
@="R&un - Stay open"
[HKEY_CLASSES_ROOT\exefile\shell\runstayopen\command]
@="cmd /k %1"
Back to index
COM support
Mingw has some support for COM programs. Programmers have had
much better luck writing COM applications in C than C++. Work is in
progress to improve support. Check the mingw32 mailing list archives
for more details on COM and more links to example files.
Back to index
Make programs
To keep from having to continually type all your compiler
commands on the command line, working with a make program is one very
good solution. There are several versions of make available both as
freeware and commercially.
Here are some URLs:
Back to index
Patches
If you have changes to source code, it may be easier to distribute
them as patches than to send the entire code to someone or list the changes by hand.
Patching is an automated process of updating files using tools such as
patch and diff.
Patches can be created by comparing two files with the diff program or
from various version control systems such as RCS. Several versions of diff
have been ported to Windows and DOS. See sites such as Virtually Un*x listed
in the Other programming tools section. There are also several versions of
patch available for use in applying patches to source code. One site that
includes it is Mumit's site also listed in the Other programming tools section.
Detailed help information on using diff and patch and the various options available
for working with them is also available in WinHelp format from the Virtually Un*x
site.
To create a patch, compare the two versions of the file with diff.
Here's an example:
diff --ignore-all-space old\file.cpp current\file.cpp > patch.fil
The example ignores whitespace and compares the old version of file.cpp
in directory old with the latest version in directory current. The
output is redirected to a file. Most patches these days also include
the -c or -u option which allows programmers
to figure out what has changed in a file by viewing the context of the
lines around it. Another common option is -r for working
with entire directories instead of single files. The option -p
may also be useful. It adds information on what C functions a change
appears in.
To patch a file, you'll need the original source file (old version)
and the file with the patches created by diff. Here's an example of
how to call patch:
patch -o file.cpp ..\old\file.cpp patch.fil
The command patches file.cpp in the old directory and outputs the updated
file to file.cpp (specified by the -o option). Another useful
switch for use with patch is -p which can affect the naming/location
of files and can be used when working with compared directories.
Back to index
GUIs/application frameworks/user interfaces
Can I use MFC or OWL?
Mingw provides access to the Win32 API. Theoretically, if you
own the MFC source code you could build MFC libraries for mingw.
No one's tried this so far. If anyone does successfully accomplish
it, please say so and it will be added to this document.
For OWL owners, there is a port with additional features which
supports various compilers including the gcc compiler line. See
http://owlnext.starbase21.com/
for details. Thanks to Greg Chicares for supplying this information.
What GUIs/application frameworks/user interface libraries are available?
There are a number of these available. The following are known
to have worked with mingw. There are several other libraries
out there.
Back to index
Libraries
If you've had luck with building other programming libraries and would like
to see them added to the list, please e-mail information on where
these libraries can be found and what you needed to do to build
them.
Here is a list of some of the libraries and programs that
can be built with mingw.
Graphics libraries
OpenGL
- Where to get it?
You can get access to OpenGL when you install a framework like
fltk or wxWindows. You can also install it yourself and
use it directly. See the Tutorials section for more information
on working with OpenGL on a Win32 platform.
If you wish to install it yourself, OpenGL and glut headers
are available from
http://www.cim.pe.u-tokyo.ac.jp/~kawachi/software/cygwin_glut-e.html
Create a GL directory under your include directory
(for example: i386-mingw32/include/GL ).
You will need to move the gl*.h files to this directory. If you
do not have glut32.dll installed on your system, move it to your
Windows system directory.
To get a copy of the glaux.h header, you can download it
from
http://people.montana.com/~bowman/Software/ming.htm
- How to compile OpenGL applications
There are some sample OpenGL programs available from
http://trant.sgi.com/opengl/examples/win32_tutorial/win32_tutorial.html
While they don't include a make file, you can compile them just
as you would any other programs. To link, don't forget the flags:
-mwindows -lglut -lglu32 -lopengl32
For the examples included at
http://www.cim.pe.u-tokyo.ac.jp/~kawachi/software/cygwin_glut-e.html,
link with the following flags:
-mwindows -lglut32 -lglu32 -lopengl32
DirectX
The latest version of DirectX for gcc is available from
http://pws.prserv.net/thefortins/cyg-directx.html
An alternative version of DirectX is available from
http://people.montana.com/~bowman/Software/ming.htm.
If you're using mingw32 version 2.95 or later, you only need
to do step 2 and add only the files that are not already in your
current mingw distribution. Many of the OpenGL and DirectX libraries and
includes have already been added to 2.95 and later distributions and
overwriting them can cause problems.
There are some compatibility issues for Windows NT 4. It does
not provide full DirectX support for the latest versions of DirectX. See
the mingw32 mailing list for more information.
For installation tips and getting started, see
http://nrmassey.future.easyspace.com/Dx
libpng and libjpeg
Information on building and using these libraries with
mingw is available from
http://www.wonderstorm.com/techstuff/gcc-mingw32.html
Mesa
See
ftp://ftp.teleport.com/pub/users/pgarceau for more information.
Simple DirectMedia Layer, libu and other multimedia libraries
http://www.devolution.com/~slouken/SDL/intro/toc.html
Simple DirectMedia Layer (SDL), cross-platform multimedia library.
http://www.rhrk.uni-kl.de/~klaux/libu.html
Libu C++ toolkit for SDL.
Also has links to cross-compiled versions of Freetype, libpng and zlib.
Database libraries
Xbase
http://linux.techass.com/projects/xdb/
Dbase/Clipper compatible, cross-platform database library.
Successfully compiled with file locking off under mingw.
MetaKit
http://www.equi4.com/metakit/
Cross platform, C++ database library.
libodbc++
http://www.orcane.net/freeodbc++/
C++ class library, similar to JDBC, for ODBC access.
Compiled and built successfully with mingw. For now, see the
mingw32 mailing list for some of the changes that were needed.
See also, ODBC access below since ODBC is required to use this library.
Oracle access
Oracle can be accessed using Oracle's pro*c and sqllib80.dll
(or sqllib18.dll for those with older versions of pro*c).
There's an example article on how to access Oracle from unsupported
compilers at http://technet.oracle.com.
Oracle's OCI interface also works in some cases using oci.dll or ociw32.dll.
If there's enough interest, I'll add source code for doing this to the FAQ as well.
ODBC access
An ODBC manager (such as ODBC Data Sources program accessible via the
Control Panel) is necessary to run ODBC programs. If anyone has any
URLs for where to get an ODBC manager, please let me know.
Some possibilities if you don't already have one on your system
are to check the following:
I'd be interested to hear if anyone has any luck with these.
Other libraries
Other programs
Back to index
Other programming tools
I have links to various tools throughout the FAQ such as
in the Make, IDEs and editors, Debugging and Other resources links, but here are
some that weren't specifically mentioned elsewhere.
- Unix style tools
Many users have found Win32 or DOS versions of Unix programming
tools very helpful. Here are some places to find ports of well-known
Unix tools.
- Other tools
For those who prefer working with tools other than those found in Unix
environments, here are some sites to check. If anyone else has favorite
programming tools to add, feel free to suggest them.
- DOS utilities,
http://www.freedos.org/freedos/software/
If you want utilities similar to standard MS DOS ones, check this
site. It even includes a deltree version that works on Windows NT. All
tools here are compiled for DOS 16 bit systems. Source is included with
most.
Back to index
How/where to report bugs
When sending in a bug report, please be sure to send a short
example of the problem. If the problem cannot be recreated, it
cannot be debugged. Also, see the list of known problems at
http://www.nanotech.wisc.edu/~khan/software/gnu-win32/gcc.html
before reporting a problem.
You can now report bugs through the mingw site hosted at Sourceforge.
You can also report bugs to cygwin. See
http://gcc.gnu.org/faq.html#bugreport for more information.
You can also bring problems up on the mingw32 mailing list.
Back to index
Other resources
If anyone has any other mingw pages they've put together that they'd like to add,
they can be placed here.
- Self-hosting version of mingw32,
ftp://ftp.franken.de/pub/win32/develop/gnuwin32/mingw32/porters/Mikey/
Emulates VC++ and GNU development environments for mingw32.
I personally recommend use of the latest versions of PDCurses (2.4) and less (346), if
you've downloaded earlier ones. See the Libraries and Other programming tools sections for
links to the latest versions.
- Miscellaneous mingw utilities and examples,
ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/misc/
Includes COM, DLL and LoadLibrary examples, redir program, patch program plus more.
- Anders Norlander's mingw32 page,
http://www.acc.umu.se/~anorland/gnu-win32/index.html
Includes various tools and utilities for mingw, including reimp, pexports
(for working with dlls) and uuidgen (for working with COM).
- Paul Sokolovsky's Development Page,
http://www.is.lg.ua/~paul/devel/
Various ports of libraries, alternative binutils and some tutorials on
dlls.
- Fredos Homepage,
http://penguin.at0.net/~fredo/
More mingw32 related ports.
- The Code Foundry,
http://www.geocities.com/SiliconValley/Station/1177/foundry.html
Win32 code including a conio library. Other useful information on
Win32 programming also available at this site.
- Command line globbing,
http://sourceware.cygnus.com/ml/cygwin/1999-11/msg00052.html
Bruce E. Wampler recommended this information on globbing for mingw.
- UTF-8 support for windres,
http://www.egroups.com/group/mingw32/1511.html
- Vijay Mukhi's Technology Cornucopia,
http://users.neca.com/vmis/
Socket, COM, OLE and other programming examples.
- The Code Project, http://www.codeproject.com/
Lots of code samples and some tutorials. Unfortunately, the emphasis here is mainly MFC and Visual C++,
but there is some Win32 code if you look for it and the site maintainers have said they'd welcome any type of
programming related submissions.
Back to index
|