title: f2py with Intel Fortran compiler
body: <p>I am trying to use f2py to interface my python programs with my Fortran modules.</p>
  
  <p>I am on a Win7 platform.</p>
  
  <p>I use latest Anaconda 64 (1.7) as a Python+NumPy stack.</p>
  
  <p>My Fortran compiler is the latest Intel Fortran compiler 64 (version 14.0.0.103 Build 20130728).</p>
  
  <p>I have been experiencing a number of issues when executing <code>f2py -c -m PyModule FortranModule.f90 --fcompiler=intelvem</code></p>
  
  <p>The last one, which I can't seem to sort out is that it looks like the sequence of flags f2py/distutils passes to the compiler does not match what ifort expects.</p>
  
  <p>I get a series of warning messages regarding unknown options when ifort is invoked. </p>
  
  <pre><code>ifort: command line warning #10006: ignoring unknown option '/LC:\Anaconda\libs'
  ifort: command line warning #10006: ignoring unknown option'/LC:\Anaconda\PCbuild\amd64'
  ifort: command line warning #10006: ignoring unknown option '/lpython27'
  </code></pre>
  
  <p>I suspect this is related to the errors I get from the linker at the end</p>
  
  <pre><code>error LNK2019: unresolved external symbol __imp_PyImport_ImportModule referenced in function _import_array
  error LNK2019... and so forth (there are about 30-40 lines like that, with different python modules missing)
  </code></pre>
  
  <p>and it concludes with a plain</p>
  
  <pre><code>fatal error LNK1120: 42 unresolved externals
  </code></pre>
  
  <p>My guess is that this is because the /link flag is missing in the sequence of options. Because of this, the /l /L options are not passed to the linker and the compiler believes these are addressed to him.</p>
  
  <p>The ifort command generated by f2py looks like this:</p>
  
  <pre><code>ifort.exe -dll -dll Pymodule.o fortranobject.o FortranModule.o module-f2pywrappers2.o -LC:\Anaconda\libs -LC:\Anaconda\PCbuild\amd64 -lPython27
  </code></pre>
  
  <p>I have no idea why the "-dll" is repeated twice (I had to change that flag from an original "-shared").</p>
  
  <p>Now, I have tried to look into the f2py and distutils codes but haven't figured out how to bodge an additional /link in the command output. I haven't even been able to locate where this output is generated.</p>
  
  <p>If anyone has encountered this problem in the past and/or may have some suggestions, I would very much appreciate it.</p>
  
  <p>Thank you for your time</p>