Printer-friendly version
warning: Creating default object from empty value in /var/www/drupal/6.x/drupal-6.26/modules/taxonomy/taxonomy.pages.inc on line 33.


TODO: Reformat to new wiki syntax.

!!! [Minimalist GNU for Windows | http://www.mingw.org]

!! MSVC and MinGW DLLs

Assume we have a testdll.h, testdll.c, and testmain.c. In the first case, we will compile testdll.c with MinGW, and let the MSVC-compiled testmain call it. You should use

gcc -shared -o testdll.dll testdll.c -Wl,--output-def,testdll.def,--out-implib,libtestdll.a

to produce the DLL and DEF files. MSVC cannot use the MinGW library, but since you have already the DEF file you may easily produce one by the Microsoft LIB tool:


Visual Basic DLL

TODO: Convert wiki syntax

Creating a MinGW DLL for Use with Visual Basic

Below are two examples of techniques which facilitate the use of use of MinGW to create DLLs, exporting functions which may be called from Visual Basic. The first of these uses C or C++ as the implementation language; the second uses GNAT/GCC.

Example 1: A DLL for Visual Basic, Programmed in C or C++

NOTE: This description is only for Visual Basic 6, not DotNet.

  • Step 1: Create your DLL.

Build a MinGW Hosted Cross Compiler for Other Platforms


TODO: Formatting -- I think I (Keith) got it right; please fix any errors.

FIXME: Software versions described are outdated; please update as appropriate, for current versions.

Building a MinGW Hosted Cross Compiler

To compile and link executables for an embedded target under windows you require a cross compiler for your required processor. This is almost as easy with a properly configured MSYS/MinGW installation as it is with a GNU/Linux machine, merely requiring a few patches for some things that aren't available in a windows native environment.

Use the thread library

TODO: Reformat

As MinGW uses the standard Microsoft C runtime library which comes with Windows, you should be careful and use the correct function to generate a new thread. In particular, the ~CreateThread function will not setup the stack correctly for the C runtime library. You should use _beginthreadex instead, which is (almost) completely compatible with ~CreateThread.

The linker consistently giving undefined references

Stop Undefined References

There are many reasons why you might receive undefined references. The typical reason is that you have not specified an appropriate library or your command line order is incorrect. In order for a library to resolve references the dependency for the library must precede the library in the command line order.

 gcc -o foo -L/path/to/mylib bar.o -lbaz

The compiler giving internal compiler errors

Why does gcc give internal error messages?

If you see diagnostic messages like

../include/wx/ctrlsub.h:156: internal error: Segmentation fault

Building a program giving me error messages


TODO: Reformat for MediaWiki formatting.


stdio.h: no such file or directory

(or another standard header)

This may be occur if you install GCC but not the w32api and mingw-runtime packages. The MinGW installer (e.g. MinGW-3.1.0-1.exe) includes all the basic packages you need: GCC, binutils, w32api, mingw-runtime and mingw32-make. See http://www.mingw.org/download.shtml.


gcc: no input files

My executable is sometimes different


  • My executable is sometimes different, when I compile and recompile the same source. Is this normal?
    • Yes, by default, and by design, ~MinGW's GCC does not produce ConsistentOutput, unless you patch it.

Environment issues


  • Why does _make_ often crash creating a sh.exe.stackdump file when I try to compile my source code?
    • If you experience random crashes with _make_ as well as with the _msysinfo_ command (_i.e._, repeating the command often allows to compile the source code succesfully), the issue might be caused by the Logitech QuickCam software. Here is provided a solution to this issue:

Specify the libraries for the linker to use


How do I specify the libraries to be searched by the linker?

  • MinGW supports libraries named according to the "<name>.lib" and "<name>.dll" conventions, in addition to the normal "lib<name>.a" convention common on *nix systems. To include libraries named according to any of these conventions, simply add an associated "-l<name>" specification to the compiler command, ensuring it is placed after the name of the module in which the reference appears.
This wiki is not a forum for discussion of usage issues. Please use the mingw-users@lists.osdn.me list instead. We do not allow creation of comments by anonymous or untrusted users, on any page.
Site Status

Site maintenance performed successfully, site online Dec 13th 12:00 AM Eastern.