[f2py] Compiling/linking the Fortran source files manually
Ben Forbes
bdforbes at gmail.com
Tue Apr 26 12:06:03 EEST 2011
It's quite strange actually. Here is a dump of helloworldmodule.o:
0000000000000000 b .bss
0000000000000000 d .data
0000000000000000 N .debug_abbrev
0000000000000000 N .debug_aranges
0000000000000000 N .debug_frame
0000000000000000 N .debug_info
0000000000000000 N .debug_line
0000000000000000 N .debug_loc
0000000000000000 N .debug_pubnames
0000000000000000 N .debug_pubtypes
0000000000000000 N .debug_str
0000000000000000 i .drectve
0000000000000000 r .rdata
0000000000000000 t .text
U HELLO
0000000000000008 C PyArray_API_F2PY
U PyFortranObject_NewAsAttr
U PyFortran_Type
U __imp_PyArg_ParseTupleAndKeywords
U __imp_PyCObject_AsVoidPtr
U __imp_PyCObject_Type
U __imp_PyDict_SetItemString
U __imp_PyErr_Format
U __imp_PyErr_NewException
U __imp_PyErr_Occurred
U __imp_PyErr_Print
U __imp_PyErr_SetString
U __imp_PyExc_AttributeError
U __imp_PyExc_ImportError
U __imp_PyExc_RuntimeError
U __imp_PyImport_ImportModule
U __imp_PyModule_GetDict
U __imp_PyObject_GetAttrString
U __imp_PyString_FromString
U __imp_PyType_Type
U __imp_Py_BuildValue
U __imp_Py_InitModule4_64
0000000000000000 t _import_array
0000000000000040 b capi_kwlist.8555
0000000000000000 d doc_f2py_rout_helloworld_hello
0000000000000020 b f2py_module_methods
00000000000002d2 t f2py_rout_helloworld_hello
0000000000000020 d f2py_routine_defs
0000000000000000 b helloworld_error
0000000000000008 b helloworld_module
0000000000000366 T inithelloworld
inithelloworld is quite plainly there at the bottom. But after getting
linked into the .dll, it must get mangled.
On Tue, Apr 26, 2011 at 6:55 PM, Ben Forbes <bdforbes at gmail.com> wrote:
> No, I believe there is still a mangling issue. Python gives an error
> along the lines of "can't find inithelloworld()".
>
> On Tue, Apr 26, 2011 at 6:50 PM, Pearu Peterson
> <pearu.peterson at gmail.com> wrote:
>>
>>
>> On 04/26/2011 11:33 AM, Ben Forbes wrote:
>>> Okay I had copied intel.py in the same directory, so it was loading it twice.
>>>
>>> I changed
>>>
>>> 'linker_so' : ['<F90>', "-shared"],
>>>
>>> to
>>>
>>> 'linker_so' : ['<F90>', "/dll"],
>>>
>>> but it's still putting it in the wrong place:
>>>
>>> C:\Program Files (x86)\Intel\Compiler\11.1\067\bin\intel64\ifort.exe
>>> /dll /dll foomodule.o fortranobject.o helloworld.o -LC:\Python27\libs
>>> -LC:\Python27\PCbuild\amd64 -lpython27 /OUT:.\foo.pyd
>>>
>>> The /dll flag needs to be after /link, right at the end. Is this a
>>> flaw with distutils?
>>
>> This is new to me. Can you give a reference for this condition?
>>
>> Note that there are two '/dll' in row, just in case it matters..
>>
>> I don't see any '/link' option in the above command.
>>
>> Finally, when you execute the command above with the right order
>> of all options, will foo.pyd be OK? Can you import it and call it from
>> Python?
>>
>> Pearu
>>
>>>
>>> On Tue, Apr 26, 2011 at 6:26 PM, Ben Forbes<bdforbes at gmail.com> wrote:
>>>> I'm attempting to implement that, but there's suddenly another problem:
>>>>
>>>> C:\Users\bdforbes\pyfor\simple_f2py>f2py -c -m foo helloworld.f90
>>>> --fcompiler=intelvem
>>>> Forcing DISTUTILS_USE_SDK=1
>>>> Traceback (most recent call last):
>>>> File "C:\Python27\Scripts\f2py-script.py", line 24, in<module>
>>>> main()
>>>> File "C:\Python27\lib\site-packages\numpy\f2py\f2py2e.py", line 561, in main
>>>> run_compile()
>>>> File "C:\Python27\lib\site-packages\numpy\f2py\f2py2e.py", line 447,
>>>> in run_compile
>>>> fcompiler.load_all_fcompiler_classes()
>>>> File "C:\Python27\lib\site-packages\numpy\distutils\fcompiler\__init__.py",
>>>> line 736, in load_all_fco
>>>> mpiler_classes
>>>> fcompiler_aliases[alias][1].__name__))
>>>> ValueError: alias 'ifort' defined for both IntelFCompiler and IntelFCompiler
>>>>
>>>> I can't remember what changed to make this happen.
>>>>
>>>>
>>>> On Tue, Apr 26, 2011 at 5:58 PM, Pearu Peterson
>>>> <pearu.peterson at gmail.com> wrote:
>>>>>
>>>>>
>>>>> On 04/26/2011 10:49 AM, Ben Forbes wrote:
>>>>>> Modifying PATH makes it find the 64-bit compiler now. However, I'm
>>>>>> still getting the same issues with the compiler and linker flags:
>>>>>>
>>>>>> ifort: command line warning #10006: ignoring unknown option '/shared'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/shared'
>>>>>> 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 '/Of'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/Oo'
>>>>>> ifort: command line warning #10006: ignoring unknown option '/Oo'
>>>>>> 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'
>>>>>> ifort: command line warning #10148: option '-Oy' not supported
>>>>>
>>>>> They are all warnings and therefore can be ignored... except
>>>>> that '/shared' and '/lpython27' options should be fixed.
>>>>> Consult the compiler help to find out how to properly
>>>>> specify these options and modify intel.py accordingly.
>>>>>
>>>>> HTH,
>>>>> Pearu
>>>>>
>>>>> _______________________________________________
>>>>> f2py-users mailing list
>>>>> f2py-users at cens.ioc.ee
>>>>> http://cens.ioc.ee/mailman/listinfo/f2py-users
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> 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
>>
>
>
>
> --
> Benjamin D. Forbes
> School of Physics
> The University of Melbourne
> Parkville, VIC 3010, Australia
>
--
Benjamin D. Forbes
School of Physics
The University of Melbourne
Parkville, VIC 3010, Australia
More information about the f2py-users
mailing list