<div class="gmail_quote">On 14 April 2012 22:40, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com">newshound2@digitalmars.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im">On 4/14/2012 2:40 AM, Vladimir Panteleev wrote:<br><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
So object files take priority over library files?<br></blockquote><br></div>Yes, because object files are NOT searched. They are incorporated. Libraries get recursively searched for unresolved symbols.<br></blockquote><br class="Apple-interchange-newline">
</div><div class="gmail_quote">I was under the impression library files were nothing more than a collection of object files?</div><div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">
On 14 April 2012 22:44, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com">newshound2@digitalmars.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is this also how ld and link.exe works?<br>
</blockquote>
<br></div>
It's how every linker I've ever used and heard of works.<br>

<br>
Keep in mind that an object file consists of blocks of BINARY data attached to symbols. There is no meaning in the binary data. The linker knows nothing about the meaning of that binary data, or where it came from. Run the "dumpobj" utility over an object file and you'll see what I mean.<br>
</blockquote><div><br></div><div>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...</div><div><br></div></div><div><div>
I just tried it, and I got the error I expected:</div><div><br></div><div>LIBCMTD.lib(atox.obj) : error LNK2005: _atoi already defined in Unit.obj</div><div><br></div><div>In C, I would always explicitly declare weak linkage to do this... what's the point of the weak attribute if not for this?</div>
</div>