[Mingw-users] Linking

Back to archive index
Keith Marshall keith****@users*****
Tue Jun 2 23:35:20 JST 2020


On 02/06/2020 12:01, Peter Williams wrote:
> I am still unsure about your comment on my link command:
> 
> gcc -o x03.exe x03.o C:\plplot32\lib\libcsirocsa.a
>   C:\plplot32\lib\libplplot.a C:\plplot32\lib\libqsastime.a
>   -mconsole -mwindows -lm

You are specifying -lm, which, although not contentious, is utterly
useless; in MinGW, it does nothing whatsoever.

You are specifying both -mconsole and -mwindows, the primary purpose of
each of which, according to the GCC manual, is to set a PE header flag
to identify your application as either a console application, (which is
the default), or as a GUI application; it can be one or the other; it
cannot be both.

Inspection of the GCC specs does indicate a side effect of -mwindows: it
causes two additional libraries -- -lgdi32 -lcomdlg32 -- to be included
in the list automatically passed to the linker; maybe, if you really do
need the PE header to target your application to the console subsystem,
but you still need to link with those libraries, you should specify them
explicitly, instead of specifying two conflicting options?

Alternatively, if your application's interface is primarily GUI, then
you should specify -mwindows, and use the Windows Console API to gain
access to properly initialized console services, when you need them,
rather than depending on you application being invoked from a console?

-- 
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.osdn.me/mailman/archives/mingw-users/attachments/20200602/a38e219c/attachment.sig>


More information about the MinGW-Users mailing list
Back to archive index