title: Linking : .a, .lib and .def files
body: <p>I am building a dll from assembly on Windows using the GNU binutils.</p>
  
  <p>I know that the dll can be either loaded when the executable is loaded or at run-time (using the LoadLibrary api call).</p>
  
  <p>For load-time loading, I seem to be only needing the dll file : no .a, .lib or .def file is needed. I wondered what these file format represent and what purpose do they serve.</p>
  
  <p>What I know and some specific questions :</p>
  
  <ul>
  <li><p>.a is the extension generally used for static library on Unix. .a files are generated with the <a href="http://www.delorie.com/gnu/docs/binutils/ld_4.html" rel="noreferrer">--out-implib</a> option of GNU ld. It is said to be an "import library", fair enough. The question is then "What good is an import library to me if I don't need it when linking ?"</p></li>
  <li><p>.lib is the extension used for static library on Windows, and according to wikipedia, is also used as "import library" under windows, so I strongly suspect they're just another name for what the binutils call .a files. True/false ?</p></li>
  <li><p>All pages I can find points that .def files list the exported symbol of the dll. Isn't that somewhat similar to what an "import library" is supposed to do ?</p></li>
  <li><p>Also, I read <a href="https://stackoverflow.com/questions/366228/def-files-c-c-dlls">here</a> that using .def files is an alternative to manually specifying exports in the source file (which I did). But I also remember reading (cannot find reference back) .def file supply an index (<a href="http://msdn.microsoft.com/en-us/library/d91k01sh%28VS.80%29.aspx" rel="noreferrer">ordinal</a>) into the exported symbols, allowing for faster run-time loading. Is that so ?</p></li>
  </ul>