title: create MSVC import library with MinGW tools
body: <p>We are currently switching the W32 build-process of a cross-platform (linux, osx, w32) project from VisualStudio to mingw.</p>
  
  <p>One of the problems we are facing is, that our projects creates a dynamic library (<code>foo.dll</code>), against which 3rd party projects can link. For this to work on W32/MSVC, an import library is required (<code>foo.lib</code>).</p>
  
  <p>Now, following <a href="http://www.mingw.org/wiki/msvc_and_mingw_dlls" rel="nofollow noreferrer">the documentation</a> it is pretty easy to create a .def file which holds all the information required for importing the library:</p>
  
  <pre><code> gcc -shared -o foo.dll foo-*.o -Wl,--output-def,foo.def
  </code></pre>
  
  <p>In order to use the <code>foo.def</code> file, the docs tell me to use the <em>Microsoft LIB</em> tool to build a <code>foo.lib</code> from it:</p>
  
  <pre><code> lib /machine:i386 /def:testdll.def
  </code></pre>
  
  <p>This obviously requires me to have (a subset of) MSVC installed on the build computer.
  However, we'd like to cross-compile the entire thing on our linux systems (probably even on some CI), which makes the installation of MSVC rather tedious.</p>
  
  <p>So I wonder, whether there's a native MinGW way to convert the <code>foo.def</code> file into a <code>foo.lib</code> import library?</p>
  
  <p>(We are aware that in the end, only MSVC users will <em>require</em> the import library and that they will have the <code>lib</code> tool ready at hand. However, since we've always shipped the <code>foo.lib</code> file, switching to <code>foo.def</code> would break 3rd parties build systems - something we would like to avoid).</p>