On 4/14/2012 4:54 PM, Manu wrote:
On 14 April 2012 22:40, Walter Bright <newshou...@digitalmars.com
<mailto:newshou...@digitalmars.com>> wrote:

    On 4/14/2012 2:40 AM, Vladimir Panteleev wrote:

        So object files take priority over library files?


    Yes, because object files are NOT searched. They are incorporated. Libraries
    get recursively searched for unresolved symbols.


I was under the impression library files were nothing more than a collection of
object files?

That's right. But if the linker just added them all in, then every program would be gigantic. So, it only adds in ones that satisfy an unresolved symbol.



I'm aware of how a linker works :) .. I wouldn't expect the linker to be able to
resolve multiply defined symbols though without instruction...

The linker does not add in library modules to add symbols that are already 
resolved.


I just tried it, and I got the error I expected:

LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in Unit.obj

In C, I would always explicitly declare weak linkage to do this... what's the
point of the weak attribute if not for this?

First you need to find out why you have multiple definitions of the same symbol being linked together. For example, do not specify libcmtd.lib to the linker, then link, then see what your unresolved symbols are.

Reply via email to