Console-free EXE with Mingw32

Colin Peters
Wed Apr 8 06:20:00 GMT 1998

Hilton Fernandes <> wrote:
> To create a console executable you use, say:
> gcc -o some_exec some_obj_1.o some_obj_2.o
> To create a console-free, GUI executable, you append
> -W1,--subsystem,windows,-e,_mainCRTStartup
> to the end of the previous command line.
> Sometimes you'll need Win32 API functions available only in GDI and USER
> Windows modules.  In that case, you should use
> -luser32 -lgdi32 -W1,--subsystem,windows,-e,_mainCRTStartup
> That is, before appending the GUI suffix, you prefix it with the

I believe those "-W1" options above should be -Wl (that is, dash double-yew
ell, not dash double-yew one). Also, if you use gcc to do your linking (as
suggested) and if your specs file is correctly set up (as it should be if
everything else is working) then you could use -mwindows to do the same
thing (and get those extra libraries too) e.g.

 gcc -o hello.exe foo.o bar.o -mwindows

If you are using 0.1.4 of Mingw32 instead of the latest snapshot (the
versions included with Jan-Jaap's versions of GCC or Mumit Khan's versions
of EGCS also use -mwindows) then you should use -windows, though I suggest
you edit the specs file and replace all occurences of %{windows: with
%{mwindows: and use -mwindows to be consistent with Cygnus and later Mingw32
releases on this.

Also, not specifying the entry point with -e _mainCRTStartup should not give
you a warning with the latest snapshot of Mingw32 (or version 0.1.4 either
if I remember correctly). Even if you do get the warning (could not find
entry point _WinMainCRTStartup or something like that) it is harmless in all
the cases I am aware of.

-- Colin Peters - colin at
-- Saga Univ. Dept. of Information Science

For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

More information about the Cygwin mailing list