[f2py] Compiling/linking the Fortran source files manually

Pearu Peterson pearu.peterson at gmail.com
Tue Apr 26 09:47:32 EEST 2011


Ok, thanks for the info.

So, the command that I would try is

   f2py -c -m foo helloworld.f90 --compiler=mingw32 --fcompiler=intelv

HTH,
Pearu

On 04/26/2011 09:39 AM, Ben Forbes wrote:
> IntelVisualFCompiler instance properties:
>    archiver        = ['C:\\Program Files
>                      (x86)\\Intel\\Compiler\\11.1\\067\\bin\\ia32\\ifort.exe',
>                      '/verbose', '/OUT:']
>    compile_switch  = '/c '
>    compiler_f77    = ['C:\\Program Files
>                      (x86)\\Intel\\Compiler\\11.1\\067\\bin\\ia32\\ifort.exe',
>                      '-FI', '-w90', '-w95', '/F6000000', '/fpe:3', '/Qopenmp',
>                      '/w', '/I:C:\\Program Files
>                      (x86)\\VNI\\imsl\\fnl600\\Intel64\\include\\dll',
>                      '/nologo', '/O3', '/Qip', '/QaxM']
>    compiler_f90    = ['C:\\Program Files
>                      (x86)\\Intel\\Compiler\\11.1\\067\\bin\\ia32\\ifort.exe',
>                      '-FR', '/F6000000', '/fpe:3', '/Qopenmp', '/w',
>                      '/I:C:\\Program Files
>                      (x86)\\VNI\\imsl\\fnl600\\Intel64\\include\\dll',
>                      '/nologo', '/F6000000', '/fpe:3', '/Qopenmp', '/w',
>                      '/I:C:\\Program Files
>                      (x86)\\VNI\\imsl\\fnl600\\Intel64\\include\\dll',
>                      '/nologo', '/O3', '/Qip', '/QaxM']
>    compiler_fix    = ['C:\\Program Files
>                      (x86)\\Intel\\Compiler\\11.1\\067\\bin\\ia32\\ifort.exe',
>                      '-FI', '-4L72', '-w', '/F6000000', '/fpe:3', '/Qopenmp',
>                      '/w', '/I:C:\\Program Files
>                      (x86)\\VNI\\imsl\\fnl600\\Intel64\\include\\dll',
>                      '/nologo', '/F6000000', '/fpe:3', '/Qopenmp', '/w',
>                      '/I:C:\\Program Files
>                      (x86)\\VNI\\imsl\\fnl600\\Intel64\\include\\dll',
>                      '/nologo', '/O3', '/Qip', '/QaxM']
>    libraries       = []
>    library_dirs    = []
>    linker_exe      = None
>    linker_so       = ['C:\\Program Files
>                      (x86)\\Intel\\Compiler\\11.1\\067\\bin\\ia32\\ifort.exe',
>                      '-shared', '-shared']
>    object_switch   = '/Fo'
>    ranlib          = None
>    version         = LooseVersion ('11.1')
>    version_cmd     = ['C:\\Program Files
>                      (x86)\\Intel\\Compiler\\11.1\\067\\bin\\ia32\\ifort.exe',
>                      '/FI', '/c',
>                      'c:\\users\\bdforbes\\appdata\\local\\temp\\tmpanswqs\\ra9
>                      py5.f', '/o',
>                      'c:\\users\\bdforbes\\appdata\\local\\temp\\tmpanswqs\\ra9
>                      py5.o']
> Fortran compilers found:
>    --fcompiler=intelv  Intel Visual Fortran Compiler for 32-bit apps (11.1)
> Compilers available for this platform, but not found:
>    --fcompiler=absoft    Absoft Corp Fortran Compiler
>    --fcompiler=compaqv   DIGITAL or Compaq Visual Fortran Compiler
>    --fcompiler=g95       G95 Fortran Compiler
>    --fcompiler=gnu       GNU Fortran 77 compiler
>    --fcompiler=gnu95     GNU Fortran 95 compiler
>    --fcompiler=intelem   Intel Fortran Compiler for EM64T-based apps
>    --fcompiler=intelev   Intel Visual Fortran Compiler for Itanium apps
>    --fcompiler=intelvem  Intel Visual Fortran Compiler for 64-bit apps
> Compilers not available on this platform:
>    --fcompiler=compaq  Compaq Fortran Compiler
>    --fcompiler=hpux    HP Fortran 90 Compiler
>    --fcompiler=ibm     IBM XL Fortran Compiler
>    --fcompiler=intel   Intel Fortran Compiler for 32-bit apps
>    --fcompiler=intele  Intel Fortran Compiler for Itanium apps
>    --fcompiler=lahey   Lahey/Fujitsu Fortran 95 Compiler
>    --fcompiler=mips    MIPSpro Fortran Compiler
>    --fcompiler=nag     NAGWare Fortran 95 Compiler
>    --fcompiler=none    Fake Fortran compiler
>    --fcompiler=pg      Portland Group Fortran Compiler
>    --fcompiler=sun     Sun or Forte Fortran 95 Compiler
>    --fcompiler=vast    Pacific-Sierra Research Fortran 90 Compiler
> For compiler details, run 'config_fc --verbose' setup command.
>
> On Tue, Apr 26, 2011 at 4:36 PM, Pearu Peterson
> <pearu.peterson at gmail.com>  wrote:
>>
>>
>> On 04/26/2011 09:31 AM, Ben Forbes wrote:
>>> When I try that I get an error:
>>>
>>> numpy.distutils.fcompiler.CompilerNotFound
>>
>> What is the output of the following command:
>>
>> f2py -c --help-fcompiler
>>
>> Pearu
>>
>>> On Tue, Apr 26, 2011 at 4:07 PM, Pearu Peterson
>>> <pearu.peterson at gmail.com>    wrote:
>>>>
>>>>
>>>> On 04/26/2011 06:09 AM, Ben Forbes wrote:
>>>>> On Mon, Apr 25, 2011 at 5:34 PM, Ben Forbes<bdforbes at gmail.com>      wrote:
>>>>>> I'm having trouble getting f2py (from Enthought 7.0.2 64-bit) to play
>>>>>> nicely with my compiler (Intel Visual Fortran 11 build 067). I am
>>>>>> running Windows 7 64-bit. My source file is just a hello world
>>>>>> subroutine, and I am running "f2py -c helloworld.f90".
>>>>>
>>>>> I've made some progress on this:
>>>>> - I use "f2py helloworld.f90" to get helloworldmodule.c.
>>>>> - I copy over fortranobject.c and fortranobject.h.
>>>>> - I manually compile the C files using mingw 64-bit to get .o files.
>>>>
>>>> Btw, have you tried
>>>>
>>>> f2py -c -m foo helloworld.f90 --compiler=mingw32 --fcompiler=intelem
>>>>
>>>> Pearu
>>>>
>>>>> - I manually compile helloworld.f90 to .obj.
>>>>> - Now I to use lib.exe (from Visual C) to link everything together.
>>>>> - I rename the resultant .lib to helloworld.pyd.
>>>>>
>>>>> The problem I'm currently getting is that when I try to "import
>>>>> helloworld", it tells me:
>>>>>
>>>>> ImportError: DLL load failed: %1 is not a valid Win32 application.
>>>>>
>>>>> It appears I need a DLL with an entry point. How would I achieve this?
>>>>>
>>>>> Here are my commands for reference:
>>>>>
>>>>> C:\MinGW_64\bin\x86_64-w64-mingw32-gcc.exe -g -DDEBUG -DMS_WIN64
>>>>> -mno-cygwin -O0 -Wall -Wstrict-prototypes
>>>>> -IC:\Python27\lib\site-packages\numpy\core\include
>>>>> -IC:\Python27\include -IC:\Python27\PC -c fortranobject.c -o
>>>>> fortranobject.o
>>>>>
>>>>> C:\MinGW_64\bin\x86_64-w64-mingw32-gcc.exe -g -DDEBUG -DMS_WIN64
>>>>> -mno-cygwin -O0 -Wall -Wstrict-prototypes
>>>>> -IC:\Python27\lib\site-packages\numpy\core\include
>>>>> -IC:\Python27\include -IC:\Python27\PC -c helloworldmodule.c -o
>>>>> helloworldmodule.o
>>>>>
>>>>> "C:\Program Files (x86)\Intel\Compiler\11.1\067\bin\intel64\ifort.exe"
>>>>> /MT /c helloworld.f90
>>>>>
>>>>> "C:\Program Files (x86)\Microsoft Visual Studio
>>>>> 9.0\VC\Bin\x86_amd64\lib.exe" fortranobject.o helloworldmodule.o
>>>>> helloworld.obj c:\Python27\libs\python27.lib /LIBPATH:"C:\Program
>>>>> Files (x86)\Intel\Compiler\11.1\067\lib\ia32" /LIBPATH:"C:\Program
>>>>> Files (x86)\Microsoft Visual Studio 9.0\VC\Lib" /LIBPATH:"C:\Program
>>>>> Files (x86)\Microsoft Visual Studio 9.0\VC\PlatformSDK\Lib"
>>>>>
>>>>>
>>>>>
>>>>>> The first
>>>>>> apparent errors are when ifort is called:
>>>>>>
>>>>>> ifort: command line warning #10006: ignoring unknown option '/shared'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/shared'
>>>>>> ifort: command line warning #10161: unrecognized source type
>>>>>> 'c:\users\bdforbes\appdata\local\temp\tmpu
>>>>>> pntzq\Release\users\bdforbes\appdata\local\temp\tmpupntzq\src.win-amd64-2.7\untitledmodule.o';
>>>>>> object f
>>>>>> ile assumed
>>>>>> ifort: command line warning #10161: unrecognized source type
>>>>>> 'c:\users\bdforbes\appdata\local\temp\tmpu
>>>>>> pntzq\Release\users\bdforbes\appdata\local\temp\tmpupntzq\src.win-amd64-2.7\fortranobject.o';
>>>>>> object fi
>>>>>> le assumed
>>>>>> ifort: command line warning #10161: unrecognized source type
>>>>>> 'c:\users\bdforbes\appdata\local\temp\tmpu
>>>>>> pntzq\Release\helloworld.o'; object file assumed
>>>>>> ifort: command line warning #10006: ignoring unknown option '/LC:\Python27\libs'
>>>>>> ifort: command line warning #10006: ignoring unknown option
>>>>>> '/LC:\Python27\PCbuild\amd64'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/lpython27'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/OU'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/OT'
>>>>>> ifort: command line warning #10155: ignoring option '/optimize';
>>>>>> argument required
>>>>>> ifort: command line warning #10006: ignoring unknown option '/O.'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/O\'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/Ou'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/On'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/Ol'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/Oe'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/O.'
>>>>>> ifort: command line remark #10010: option '/Op' is deprecated and will
>>>>>> be removed in a future release.
>>>>>> See '/help deprecated'
>>>>>>
>>>>>> Is it possible for me to provide f2py with a pre-compiled object file
>>>>>> or static library? I know how to produce .obj and .lib, not sure how
>>>>>> to turn those into .o or .a or .so.
>>>>>>
>>>>>> Thanks for your help.
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Benjamin D. Forbes
>>>>>> School of Physics
>>>>>> The University of Melbourne
>>>>>> Parkville, VIC 3010, Australia
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> f2py-users mailing list
>>>> f2py-users at cens.ioc.ee
>>>> http://cens.ioc.ee/mailman/listinfo/f2py-users
>>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> f2py-users mailing list
>> f2py-users at cens.ioc.ee
>> http://cens.ioc.ee/mailman/listinfo/f2py-users
>>
>
>
>



More information about the f2py-users mailing list