This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc -Wl,--subsystem,windows -mwindows options

"Glenn A. Carlson, P.E." <> writes:

> -Wl,--subsystem,windows -mwindows
> What exactly do these gcc options do?  Are they preprocessor, compiler, or
> linker options?  Sometimes I only need -windows; sometimes I need both.  How
> do I know when I will need both or just -mwindows?

As you discovered, -Wl,--subsystem,windows passes `--subsystem
windows' to the linker.  -mwindows is a compiler option; however, it's
only affect is on the options which the compiler passes to the

For the linker, --subsystem is documented in the linker manual as

    @kindex --subsystem
    @item --subsystem @var{which}
    @itemx --subsystem @var{which}:@var{major}
    @itemx --subsystem @var{which}:@var{major}.@var{minor}
    Specifies the subsystem under which your program will execute.  The
    legal values for @var{which} are @code{native}, @code{windows},
    @code{console}, and @code{posix}.  You may optionally set the
    subsystem version also.
    [This option is specific to the i386 PE targeted port of the linker]

Admittedly that is not particularly informative.  As far as I can see
from the code, the effect is to set the entry point to
WinMainCRTStartup, and to set the symbol __subsystem__ to 2.
Presumably this is something the Microsoft linker also does.

For the compiler, from the source code, the effect of -mwindows is to
add -lgdi32 and -lcomdlg32 to the list of default libraries (the uwin
target also adds -luser32), and to pass --subsystem windows to the

So it seems that if you use -mwindows you shouldn't need to also use
-Wl,--subsystem,windows, since that will happen anyhow, at least for
the cygwin, mingw32, and uwin targets.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]