I have to create a python wrapper for a large C library. I am trying to use the ctypes module to do this however I am getting an error when I try to load the shared library. Here is the python code I’m running at the moment.
import ctypes
praatlib_path = '/n/banquet/da/martega/Programming/libs/libpraat.so'
praatlib = ctypes.CDLL(praatlib_path)
print 'Hello, World!'
Unfortunately, I’m getting the following error which I don’t know enough to debug:
Traceback (most recent call last):
File "./praatlib.py", line 9, in <module>
praatlib = ctypes.CDLL(praatlib_path)
File "/usr/local/lang/python-2.7.3/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /n/banquet/da/martega/Programming/libs/libpraat.so: undefined symbol: _Znaj
Can anyone explain what this means and how I can go about fixing it?
In case it’s useful, here’s the command in the Makefile that builds the shared library.
gcc -shared -Wl,-soname,libpraat.so -o libpraat.so `find num glpk audio stat LPC FFNet dwtools artsynth fon dwsys GSL kar FLAC mp3 library -name "*.o"`
Edit: I recompiled it with g++ instead of C++. This fixed the original error but now I’m getting the following error which is something I’ll probably have to fix on my own:
Traceback (most recent call last):
File "./praatlib.py", line 9, in <module>
praatlib = ctypes.CDLL(praatlib_path)
File "/usr/local/lang/python-2.7.3/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /n/banquet/da/martega/Programming/libs/libpraat.so: undefined symbol: Melder_hasError
The missing symbol
_Znajdemanges tooperator new[](unsigned int):Try to compile your library using g++ instead of gcc