Quantcast

C Runtime Library When Linking With LD?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

C Runtime Library When Linking With LD?

Mike Crawford
Please forgive me as this is obviously a frequently asked question.
However I'm unable to find the answer with a search engine.

I want to build libbz2.dll - the BZip2 library as a Windows DLL.  It
compiles just fine but I'm unclear what to put in my makefile so that ld
finds a C Runtime.

There is a blog at Microsoft that discourages linking to MSVCRT.DLL.  Am
I to link to it anyway?  If so how do I do it?

Is there some other runtime I should use?  If so can I statically link
it or must I distribute the runtime's DLL with my installer?

Thank you

-- New To MinGW

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

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.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: C Runtime Library When Linking With LD?

Keith Marshall
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 27/09/16 04:27, Mike Crawford wrote:
> Please forgive me as this is obviously a frequently asked question.
>  However I'm unable to find the answer with a search engine.

Better to ask, than to blindly follow potentially misleading info on
some random, ill-informed web site; (yes, StackOverflow, I hold you
accountable for a great deal of ill-informed rubbish).

> I want to build libbz2.dll - the BZip2 library as a Windows DLL.
> It compiles just fine but I'm unclear what to put in my makefile so
> that ld finds a C Runtime.

If you are using MinGW, you don't need to add *anything*; just use gcc
or g++ (*not* ld) to invoke the linker, and it will specify MSVCRT.DLL
automatically (by default).

> There is a blog at Microsoft that discourages linking to
> MSVCRT.DLL.

This may be a valid concern, *if* you are using Microsoft's compiler;
(you do *not* want to mix MSVCRT.DLL and the (non-free) runtime which
accompanies that (equally non-free[1]) compiler).  Since you are using
MinGW, that discouragement is no more than Microsoft brainwashing.

[1]: Before some smart Alec points out that there are zero-price ways
to acquire Microsoft compilers, please remember that they are still
encumbered by restrictive EULAs.  Zero-price != free.

> Am I to link to it anyway?

Yes.

> If so how do I do it?

Use gcc, (or g++, if your application is C++), or any of the other
GCC compiler language drivers, (as appropriate), as the command to link
your application, and it will be done automatically.  (Do *not* invoke
ld directly; that doesn't comprehend the library dependencies).

> Is there some other runtime I should use?

No.

> If so can I statically link it or must I distribute the runtime's
> DLL with my installer?

You cannot do that legally, (for MSVCRT.DLL); nor do you need to, since
it is already distributed as an OS component.  There is one issue[2] you
may need to consider: MSVCRT.DLL has evolved with Windows itself; if you
use features added by a recent Windows OS version, your application may
not run on an older Windows version.

[2]: There may be other, usage related issues, (e.g. within MSVCRT.DLL,
time_t means 32-bit time, irrespective of _USE_32BIT_TIME_T); however,
these are separate from the issues of linking and distribution.

- --
Regards,
Keith.

Public key available from keys.gnupg.net
Key fingerprint: C19E C018 1547 DE50 E1D4 8F53 C0AD 36C6 347E 5A3F
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (GNU/Linux)

iQIcBAEBAgAGBQJX6mfaAAoJEMCtNsY0flo/jvEQAL1fjtAhtOcYRzzSGSbfhAvq
k1od/yBvgTJUQPq8taC5RupsjSMQgWx6thbG4kJnWuXImb4hId+8XmjaGB3SCtDN
FbQBgVdVIrAXHkzo0vVaco0B7Zrk6LvM1wkX1smjAqrItSkF1Saeffc/BHr9/R1K
lb2r7sMi2MBaOe3CdpMdNPb53BSFBGRHE37j9eb+zdziIZmaGUDfVxE0y1I2xT+y
3GZMFPy4fqd2bsG+26gvuTRYl9jPfrHCdORKG6lq9ONipr9QFyxAH556Zwb16Ntp
O0+XjH3/AYSxxrbzB6zcQ/dkm2oB7PYPTTGHhbxGv2yUvIpSSh1obJ6NohhiSK0V
fbgew9+ge/ebRzB6krpqFl5GDmJKt9zEguBk/C4kcU/5Odh4WXBnxx+yMkhoG3Nc
33dlMBLiOVY7sdEH5UwTDHysCf7aX8u1rmKlwcmYYNYeyEJZR09AyKTmw6QQWNoW
Iu3jo97JJ3uamlqUxkS0CvvmroppFvv4ybeLkrcMayxXbjQluzqjlhflJjVcfUT/
cGYYjgmo0kNGbG9DMRqrFrwJ5cGYHWFvRn7QzxNJB/nxVVs62oYiPylFvkTVHIfq
fUzTViqTTm0b4FYNmbmA6RzJsu90ZF8tQPV5mTp+LT9h0eBdOZEKH9O6hYgZ83V2
xfOOz8J7y5Ys1a0hnq4d
=t0gH
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
[hidden email]

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.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Loading...