Hi, I am investigating the use of ctypes to write C extensions for numpy/scipy. First, thank you for the wiki, it makes it easy to implement in a few minutes a wrapper for a C function taking arrays as arguments. I am running recent SVN version of numpy and scipy, and I couldn't make load_library work as I expected: Let's say I have a libhello.so library on linux, which contains the C function int sum(const int* in, size_t n). To wrap it, I use:
import numpy as N from ctypes import cdll, POINTER, c_int, c_uint _hello = cdll.LoadLibrary('libhello.so') _hello.sum.restype = c_int _hello.sum.artype = [POINTER(c_int), c_uint] def sum(data): return _hello.sum(data.ctypes.data_as(POINTER(c_int)), len(data)) n = 10 data = N.arange(n) print data print "sum(data) is " + str(sum(data)) 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 ? David ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion