[Numpy-discussion] New to ctypes. Some problems with loading shared library.

Lou Pecora lou_boog2000@yahoo....
Tue Feb 5 10:25:47 CST 2008


I got ctypes installed and passing its own tests.  But
I cannot get the shared library to load.  I am using
Mac OS X 10.4.11, Python 2.4 running through the
Terminal.

I am using Albert Strasheim's example on
http://scipy.org/Cookbook/Ctypes2 except that I had to
remove the defined 'extern' for FOO_API since the gcc
compiler complained about two 'externs' (I don't
really understand what the extern does here anyway). 

My make file for generating the library is simple,

# ---- Link ---------------------------
test1ctypes.so:  test1ctypes.o  test1ctypes.mak
	gcc -bundle -flat_namespace -undefined suppress -o
test1ctypes.so  test1ctypes.o

# ---- gcc C compile ------------------
test1ctypes.o:  test1ctypes.c test1ctypes.h
test1ctypes.mak
	gcc -c test1ctypes.c -o test1ctypes.o

This generates the file test1ctypes.so.  But when I
try to load it

import numpy as N
import ctypes as C

_test1 = N.ctypeslib.load_library('test1ctypes', '.')

I get the error message,

OSError: dlopen(/Users/loupecora/test1ctypes.dylib,
6): image not found

I've been googling for two hours trying to find the
problem or other examples that would give me a clue,
but no luck.  

Any ideas what I'm doing wrong?  Thanks for any clues.






-- Lou Pecora,   my views are my own.


      ____________________________________________________________________________________
Never miss a thing.  Make Yahoo your home page. 
http://www.yahoo.com/r/hs


More information about the Numpy-discussion mailing list