title: Call a DLL from Haskell
body: <p>I have a Windows DLL named <code>Foo.dll</code>. It exports (amoung other things) the following:</p>
  
  <pre><code>extern "C" __declspec(dllexport) unsigned int Version();
  </code></pre>
  
  <p>How do I write a Haskell program which calls this function and prints out the answer?</p>
  
  <p>I managed to figure out that I can write this:</p>
  
  <pre><code>foreign import ccall "Version" cpp_Version :: CUInt
  </code></pre>
  
  <p>This compiles just fine, but utterly fails to link. This is not surprising; at this point GHC has <em>no idea</em> where the hell to look for this function. But I can't figure out what magic button I need to push to make this happen. Can anybody tell me how to get this to build sucessfully?</p>
  
  <p>(I'm also not 100% sure whether the calling convention should be <code>ccall</code> or <code>stdcall</code>; what's the difference?)</p>