<div dir="ltr">Yes, the linker matches up these symbols. The linker uses an import library to look up symbols exported by a DLL. MSVCR*.DLL's export library is MSVCRT.lib. You can see the contents of the import library using dumpbin command.<div>

<br></div><div><div><font face="courier new, monospace">C:\> dumpbin /headers "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\LIB\MSVCRT.lib"</font></div><div><font face="courier new, monospace">  </font></div>

<div><font face="courier new, monospace">  Version      : 0</font></div><div><font face="courier new, monospace">  Machine      : 14C (x86)</font></div><div><font face="courier new, monospace">  TimeDateStamp: 524F7A25 Sat Oct 05 11:32:05 2013</font></div>

<div><font face="courier new, monospace">  SizeOfData   : 00000015</font></div><div><font face="courier new, monospace">  DLL name     : MSVCR120.dll</font></div><div><font face="courier new, monospace">  Symbol name  : _printf</font></div>

<div><font face="courier new, monospace">  Type         : code</font></div><div><font face="courier new, monospace">  Name type    : no prefix</font></div><div><font face="courier new, monospace">  Hint         : 1789</font></div>

<div><font face="courier new, monospace">  Name         : printf</font></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">(Because I'm using MSVC 2013, the library's version number is 130, but it's not important.)<br>

</div><div class="gmail_extra"><br></div><div class="gmail_extra">As you can see, the symbol defined by MSVCRT.LIB is _printf, so undefined symbol _printf will be resolved with this library. The symbol name used by the static linker does not have to be the same as the name used by the dynamic linker. When the (static) linker creates the import table entry for _printf in the executable, it mangled the name as specified by "Name type" field. It's "no prefix" in this case, which make the linker to strip the beginning underscore.</div>

<div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_quote">On Sun, Dec 22, 2013 at 8:22 PM, Astron B <span dir="ltr"><<a href="mailto:boldaster@gmail.com" target="_blank">boldaster@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi.<br><br>I compiled some simple code using clang that prints to console using printf. When I check the name of the symbols in the compiled object file I find <br>

<br></div>_printf<br><br></div>
I'm wondering why the name appears to be mangled when the printf function in msvcr110.dll is simply "printf." How does the linker match up these symbols correctly? <br><br></div>Thanks.<br></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div>