I am trying to use f2py to interface my python programs with my Fortran modules.
I am on a Win7 platform.
I use latest Anaconda 64 (1.7) as a Python+NumPy stack.
My Fortran compiler is the latest Intel Fortran compiler 64 (version 14.0.0.103 Build 20130728).
I have been experiencing a number of issues when executing f2py -c -m PyModule FortranModule.f90 --fcompiler=intelvem
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.
I get a series of warning messages regarding unknown options when ifort is invoked.
ifort: command line warning #10006: ignoring unknown option '/LC:Anacondalibs'
ifort: command line warning #10006: ignoring unknown option'/LC:AnacondaPCbuildamd64'
ifort: command line warning #10006: ignoring unknown option '/lpython27'
I suspect this is related to the errors I get from the linker at the end
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)
and it concludes with a plain
fatal error LNK1120: 42 unresolved externals
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.
The ifort command generated by f2py looks like this:
ifort.exe -dll -dll Pymodule.o fortranobject.o FortranModule.o module-f2pywrappers2.o -LC:Anacondalibs -LC:AnacondaPCbuildamd64 -lPython27
I have no idea why the "-dll" is repeated twice (I had to change that flag from an original "-shared").
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.
If anyone has encountered this problem in the past and/or may have some suggestions, I would very much appreciate it.
Thank you for your time
See Question&Answers more detail:
os