Re: Linking

Keith Marshall <[email protected]> Tue, 2 Jun 2020 15:35:20 +0100
Newsgroups gmane.comp.gnu.mingw.user
Organization MinGW.org Project
Message-ID <[email protected]>
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

_______________________________________________
MinGW-Users mailing list
[email protected]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEwZ7AGBVH3lDh1I9TwK02xjR+Wj8FAl7WY6kACgkQwK02xjR+
Wj/7vA//X0y5sk6HMFHtk9MGgJ7Yr1XgyT5Ag5Kxi4g3wkF3xU+6Je5wq6saOLDa
SRN2/uYLRwSYtGDhwL5GtrfGZpluYiF2fcreI2XMqLyEaoUOMkpYjD3/jpAsfkq4
H0bZwGAhYvRo3Vp2GWYsz496SM5cid1/XZeW1wDqX01K/EUA8e6VsNacmZksKkR1
MDZ8bAhMx8uRWeKOxTCZz0Xd99+DujppFBYgCwnWJpz9fCuSxzaRjNcamrBm7L0K
QZPBZVwcULL+avNiapvGwgqH3WSOeMZyAXtMN8913qDORfHe+uGhguJVfHhptmjA
5K3jKKJ9dLc9KaSrQNx9RZHLXiL9slP5kLUu3XGwpLh9up0RDf8Ku1liif18Rv75
V5y29Zwa+Xm8Ov1hJDjD0E/kzTqfzWSFU7c1/r7PeuHvHnnNyUsPL5CLsx0Nu2+G
Vn14L4iTyu8aHGCFSwxWT0mT75JpNBrCEf4lkPjqO5PUAetO3IjC9cayrlUKncCr
Gw+f8fCl4JkehIuO2JcjX4T8rcchfw2WKiRY5lc8vIZQ8dtQUieD9cCrkksOQpy5
XqqhR8RLEwvgXW47Nl/eul/9EfcwaW/qOLHUKC3KGK4z89ytshRDPBPoFzLBYDBO
cy6oq3IrcB6BfFGOxbPq0v6ChZkEj2VqOFFYXJDw6YRyODagcNM=
=urrs
-----END PGP SIGNATURE-----