José Gómez-Dans | 25 Nov 16:05 2010
Picon
Picon

Accessing fortran libraries

Hi,

I would like to access a fortran DLL in linux (x86_64) using ctypes. I thought that this would be transparent, but if I try I get the following problems

mylib = ctypes.CDLL ("./libmylib_x86_64.so")

OSError                                   Traceback (most recent call last)

OSError: ./libmylib_x86_64.so: undefined symbol: _gfortran_internal_malloc64

Out of interest, I tried ld on the library, and I found that other gfortran-related functions are missing, as well as some from math.h (for example, log, cos, sin,  _gfortran_transfer_real, _gfortran_st_write, _gfortran_pow_r8_i4, _gfortran_internal_unpack, _gfortran_st_write_done, etc.). I link code to this library and it works, but I would like to access the library from python.

There's something I am obviously  missing, but I don't even know where to start looking! Any hints greatly appreciated.

Thanks!
Jose

--
RSU ■ Dept. of Geography ■ University College ■ Gower St, London WC1E 6BT UK
EMM ■ Dept. of Geography ■ King's College ■  Strand, London WC2R 2LS UK

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Andrew MacIntyre | 26 Nov 00:12 2010
Picon

Re: Accessing fortran libraries [SEC=UNCLASSIFIED]

Those routines are likely to be in a fortran runtime library.  You probably need to use the RTLD_GLOBAL flag when loading your fortran SO to have the symbols resolved.

 

-------------------------> "These thoughts are mine alone!" <---------

Andrew MacIntyre           Operations Branch

tel:   +61 2 6219 5356     Communications Infrastructure Division

fax:   +61 2 6253 3277     Australian Communications & Media Authority

email: andrew.macintyre <at> acma.gov.au            http://www.acma.gov.au/

 

From: José Gómez-Dans [mailto:j.gomez-dans <at> geog.ucl.ac.uk]
Sent: Friday, 26 November 2010 2:06 AM
To: ctypes-users
Subject: [ctypes-users] Accessing fortran libraries

 

Hi,

I would like to access a fortran DLL in linux (x86_64) using ctypes. I thought that this would be transparent, but if I try I get the following problems

mylib = ctypes.CDLL ("./libmylib_x86_64.so")

OSError                                   Traceback (most recent call last)

OSError: ./libmylib_x86_64.so: undefined symbol: _gfortran_internal_malloc64

Out of interest, I tried ld on the library, and I found that other gfortran-related functions are missing, as well as some from math.h (for example, log, cos, sin,  _gfortran_transfer_real, _gfortran_st_write, _gfortran_pow_r8_i4, _gfortran_internal_unpack, _gfortran_st_write_done, etc.). I link code to this library and it works, but I would like to access the library from python.

There's something I am obviously  missing, but I don't even know where to start looking! Any hints greatly appreciated.

Thanks!
Jose

--
RSU ■ Dept. of Geography ■ University College ■ Gower St, London WC1E 6BT UK
EMM ■ Dept. of Geography ■ King's College ■  Strand, London WC2R 2LS UK

NOTICE: This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply email and destroy all
copies of the original message.

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
José Gómez-Dans | 26 Nov 11:42 2010
Picon
Picon

Re: Accessing fortran libraries [SEC=UNCLASSIFIED]

Hi,

On Thu, Nov 25, 2010 at 11:12 PM, Andrew MacIntyre <Andrew.MacIntyre <at> acma.gov.au> wrote:

Those routines are likely to be in a fortran runtime library.  You probably need to use the RTLD_GLOBAL flag when loading your fortran SO to have the symbols resolved.


Mmmm, tried that but doesn't seem to help:
ctypes.CDLL("./libmylib_x86_64.so", mode=ctypes.RTLD_GLOBAL)
[ ... ]
OSError: ./libmylib_x86_64.so: undefined symbol: _gfortran_internal_malloc64




--
RSU ■ Dept. of Geography ■ University College ■ Gower St, London WC1E 6BT UK
EMM ■ Dept. of Geography ■ King's College ■  Strand, London WC2R 2LS UK
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users
Andrew MacIntyre | 29 Nov 00:34 2010
Picon

Re: Accessing fortran libraries [SEC=UNCLASSIFIED]

Hmmm...  the only result I get from googling the specific symbol you’re having trouble with is at http://forums.amd.com/forum/messageview.cfm?catid=217&threadid=90399.

 

That thread suggests to me the possibility that there may be a mismatch between the version of gfortran used to build your target library and the version of libgfortran that is being loaded by the runtime linker.  If you haven’t already, check that you have all the necessary runtime libraries in place.

 

Running ldd against your target SO might help figure out which libraries might are being picked up. 

 

-------------------------> "These thoughts are mine alone!" <---------

Andrew MacIntyre           Operations Branch

tel:   +61 2 6219 5356     Communications Infrastructure Division

fax:   +61 2 6253 3277     Australian Communications & Media Authority

email: andrew.macintyre <at> acma.gov.au            http://www.acma.gov.au/

 

From: José Gómez-Dans [mailto:j.gomez-dans <at> geog.ucl.ac.uk]
Sent: Friday, 26 November 2010 9:43 PM
To: ctypes-users
Subject: Re: [ctypes-users] Accessing fortran libraries [SEC=UNCLASSIFIED]

 

Hi,

On Thu, Nov 25, 2010 at 11:12 PM, Andrew MacIntyre <Andrew.MacIntyre <at> acma.gov.au> wrote:

Those routines are likely to be in a fortran runtime library.  You probably need to use the RTLD_GLOBAL flag when loading your fortran SO to have the symbols resolved.


Mmmm, tried that but doesn't seem to help:
ctypes.CDLL("./libmylib_x86_64.so", mode=ctypes.RTLD_GLOBAL)
[ ... ]
OSError: ./libmylib_x86_64.so: undefined symbol: _gfortran_internal_malloc64




--
RSU ■ Dept. of Geography ■ University College ■ Gower St, London WC1E 6BT UK
EMM ■ Dept. of Geography ■ King's College ■  Strand, London WC2R 2LS UK

NOTICE: This email message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not the
intended recipient, please contact the sender by reply email and destroy all
copies of the original message.

------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
ctypes-users mailing list
ctypes-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ctypes-users

Gmane