Re: Linking libraries
On 2010-07-03 08:23:48 -0400, Giuliano Bertoletti said:
Alf P. Steinbach /Usenet ha scritto:
* Giuliano Bertoletti, on 03.07.2010 08:58:
But it's impossible to say for sure whether the reason that it is that
way, is incompetence or evilness or politics. My guess is sheer
incompetence. For example, you have to /coerce/ the MS tools to accept
a standard 'main' for a GUI subsystem Windows program, and it's
difficult to imagine anything but sheer incompetence as the reason --
and so also for the runtime-lib dependencies.
Yes, I see. But aside from the reason why they did it in such a way,
what is the difference between various settings in the final code?
I mean, do the linker really throws libc & co. inside the .lib when
grouping the .objs?
Microsoft's compiler puts the name of the runtime library that a file
was compiled for (based on compiler flags) into that file's object
file, and the linker uses that information to pick library files to
link with. That simplifies the linker's command line, since it doesn't
have to include most library names, and it helps protect against
mismatches in compiler switches: if one object file was built for
multi-threading and another for a single thread, there will be two
runtime library specifications, and the linker will warn about the
conflict. Unfortunately, Microsoft's document, while explaining this,
also suggests that you simply suppress the warning (well, that was the
advice back when I was dealing with this, four or five years ago). The
result is usually a disaster.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)