title: f2py with intelvem (Windows): Fortran functions get linked to kernel32.dll leading to ImportError
body: <p>When using f2py (Windows 7 64, Intel VS2008 C &amp; Visual Fortran Composer XE 2011 compilers, Python 2.7, numpy 1.9.2) to convert FORTRAN90 source to a Python DLL, the f2py process completes without error, but the DLL will not <code>import</code> into Python, throwing the following error:</p>
  
  <pre><code>&gt;&gt;&gt; import superdll
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ImportError: DLL load failed: The specified procedure could not be found.
  </code></pre>
  
  <p>Using <code>ctypes</code> to import the .pyd file displays a more useful error:</p>
  
  <pre><code>import ctypes
  ctypes.CDLL('superdll.pyd')
  </code></pre>
  
  <p>Prompts a popup windows stating:</p>
  
  <pre><code>"The procedure entry point for_getcmd_arg could not be located in the dynamic link library KERNEL32.DLL."
  </code></pre>
  
  <p>Using <a href="http://www.dependencywalker.com/" rel="nofollow noreferrer">Dependency Walker</a>, I have found that my Fortran procedures/functions are trying to be linked to <code>Kernel32.dll</code>, where they are obviously not present (see pic below).  These same Fortran procedures/functions are linked, correctly, to <code>libifcoremd.dll</code> (part of Visual Fortran Composer).</p>
  
  <p><img src="https://i.stack.imgur.com/IzSU9.jpg" alt="enter image description here"></p>
  
  <p>Any suggestions to fixing what appears to be an unnecessary linking to <code>kernel32.dll</code> using VS2008 linker with Visual Fortran compiler (ifort)?</p>
  
  <p>Note: all of this works using Cygwin and RHEL with the same versions of Python &amp; numpy, but using the GNU 4.4 equivalent compilers.</p>
  
  <p><strong>EDIT</strong>:  Added command line calls:</p>
  
  <p><strong>f2py call:</strong></p>
  
  <pre><code>f2py.py -c --fcompiler=intelvem &lt;list of .f90 files&gt; -m superdll
  </code></pre>
  
  <p><strong>VS C compiler calls:</strong></p>
  
  <pre><code>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I&lt;path/to/source&gt; -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tc&lt;path/to&gt;\superdllmodule.c /Fo&lt;path/to&gt;\superdllmodule.obj
  
  C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I&lt;path/to/source&gt; -IC:\Python27\lib\site-packages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC /Tc&lt;path/to&gt;\fortranobject.c /Fo&lt;path/to&gt;\fortranobject.obj
  </code></pre>
  
  <p><strong>Fortran compiles</strong></p>
  
  <pre><code>(I can include this if needed)
  </code></pre>
  
  <p><strong>Linker call:</strong></p>
  
  <pre><code>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /EXPORT:initsuperdll &lt;path/to/&gt;superdllmodule.obj &lt;path/to/&gt;fortranobject.obj &lt;list of .o files&gt; &lt;path/to/&gt;superdll-f2pywrappers2.o /OUT:.\superdll.pyd /IMPLIB:&lt;path/to/&gt;superdll.lib /MANIFESTFILE:&lt;path/to/&gt;superdll.pyd.manifest
  </code></pre>