Hi,<br><br>I know this is a pretty simple question but I've spent a while on this and can't see whats wrong. I'm trying to access a shared library which I've created called Simulation.so, its created as such (snip from makefile): <br>
<br>all: simulation<br><br>simulation: Simulation.so<br><br>Simulation.so: Simulation.o Statistics.o<br> gcc -shared Simulation.o Statistics.o -L/usr/local/lib -lsbml -lstdc++ -lm -o Simulation.so<br><br>Statistics.o: Statistics.c Statistics.h<br>
gcc -fpic -g -O2 -I/usr/include -c Statistics.c<br><br>Simulation.o: Simulation.c<br> gcc -fpic -g -O2 -I/usr/include -c Simulation.c<br><br>and I can load it properly in python <br><br>import ctypes<br>t = ctypes.CDLL('./Simulation.so')<br>
this works fine, I have a simple function I ve put in for testing which just returns the integer 4. However when I try to access this function it doesnt work<br>t.test()<br> File "<stdin>", line 1, in <module><br>
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ctypes/__init__.py", line 325, in __getattr__<br> func = self.__getitem__(name)<br> File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/ctypes/__init__.py", line 330, in __getitem__<br>
func = self._FuncPtr((name_or_ordinal, self))<br>AttributeError: dlsym(0x81e6b0, test): symbol not found<br><br>I've tried using<br>t.__getattr__("test")<br>but still have the same exception, I've tried loading the library with mode = RTLD_GLOBAL aswell and still have no luck. As far I as I can see this should work? But as I am just starting with ctypes I am sure I doing something sorry very stupid. <br>
<br>Any pointers would be greatly appreciated,<br><br>Many thanks in advance,<br><span class="sg"><br>Nathan<br><br><br>Im hoping python-list is ok for questions regarding ctypes :S<br>
</span>