title: gfortran, DLL, underscore
body: <p>I want to access some subroutines from a third party DLL. The functions use STDCALL as the calling convention.</p>
  
  <p>Running <code>dumpbin /export foo.dll</code> gives me something like:</p>
  
  <pre><code>      ...
        7    6 00004B40 Foo@16
        ...
  </code></pre>
  
  <p>I compile my code using:</p>
  
  <pre><code>      gfortran test.f90 -o test.exe -Wl,foo.dll
  </code></pre>
  
  <p>I get an error: <code>undefined reference to '_foo_'</code> (note the underscores).</p>
  
  <p>I have tried adding the <code>-mrtd</code> compilation flag, as well as other flags I googled, all to no avail.</p>
  
  <p><strong>How can I tell fortran to not add the underscores?</strong></p>
  
  <hr>
  
  <p><strong>edit:</strong> A bit of clarification is in order.</p>
  
  <ol>
  <li>I have an existing DLL to which I do not have the source to.</li>
  <li>This DLL is written in Visual Basic, if it helps.</li>
  <li>I want to call this DLL <em>from</em> fortran.</li>
  <li>When I write in test.f90: <code>Foo(1.0d0)</code> I get an <code>undefined reference to '_foo_'</code> linkage error</li>
  </ol>