[Numpy-discussion] ctypes: how does load_library work ?

David Cournapeau david at ar.media.kyoto-u.ac.jp
Fri Aug 18 06:42:22 CDT 2006

Albert Strasheim wrote:
> Hello all
>> -----Original Message-----
>> From: numpy-discussion-bounces at lists.sourceforge.net [mailto:numpy-
>> discussion-bounces at lists.sourceforge.net] On Behalf Of David Cournapeau
>> Sent: 18 August 2006 06:55
>> To: Discussion of Numerical Python
>> Subject: [Numpy-discussion] ctypes: how does load_library work ?
>> <snip>
>> That works OK, but to avoid the platform dependency, I would like to use
>> load_library from numpy: I just replace the cdll.LoadLibrary by :
>> _hello = N.ctypeslib.load_library('hello', '.')
>> which does not work. The python interpreter returns a strange error
>> message, because it says hello.so.so is not found, and it is looking for
>> the library in the directory usr/$(PWD), which does not make sense to
>> me. Is it a bug, or am I just not understanding how to use the
>> load_library function ?
> load_library currently assumes that library names don't have a prefix. We
> might want to rethink this assumption on Linux and other Unixes.
I think it needs to be modified for linux and Solaris at least, where 
the prefix lib is put in the library name. When linking, you use -lm, 
and not -llibm. In dlopen, you use the full name (libm.so).

After a quick look at ctypes reference doc, it looks like there are some 
function to search a library, maybe this can be used ?

Anyway, this is kind of nickpicking, as ctypes is really a breeze to 
use. To be able to do the whole wrapping in pure python is great, thanks !


More information about the Numpy-discussion mailing list