Hi,
I've tried searching for topics related to dlopen() of dynamic libraries in the
list but there's nothing relevant or recent.
I'm facing a problem with a 3rd party C/C++ Framework (dynamic library) on Mac
OS X which I'm trying to import into Python using ctypes. Unfortunately OS X
has deprecated a function which is called from the Framework and is no longer
available as of 10.8+ (Mtn. Lion, now updated to Mavericks). In addition, there
is no recent version of the 3rd party framework available and it does not look
like it's actively updated. (The 3rd party framework in question is the Fantom
framework/driver for the LEGO Mindstorms NXT/EV3).
Existing tools using the 3rd party framework runs ok, but attempting to access
it using ctypes fails with a Symbol not Found error when Python 2.7.x attempts
to dlopen() the library. I suspect it is due to the setting of RTLD_NOW when
opening the framework. I'd like to try to specify RTLD_LAZY instead.
Unfortunately sys.setdlopenflags(0) does not appear to do anything. RTLD_NOW is
still set, which I presume overrides RTLD_LAZY if both flags were set. I've
tried this with both the Apple supplied python and the version from MacPorts.
Enclosed is a snippet of the code and the Traceback. Is there a way to force
RTLD_NOW off?
[code]
# Load library.
#dll = ctypes.cdll.LoadLibrary(libpath)
RTLD_LAZY = 1
sys.setdlopenflags(0)
print "dlopen() flags = %d" % sys.getdlopenflags()
dll = ctypes.CDLL(libpath, RTLD_LAZY)
[/code]
[traceback]
$ arch -i386 python --version
Python 2.7.5
$ arch -i386 python pyfantom.py
Running on Darwin Platform (Rel. 13.0.0)
Bluetooth Stack not supported (Rel >= 12.0.0)
Found Fantom Library ( /Library/Frameworks/fantom.framework/fantom )
dlopen() flags = 0
Traceback (most recent call last):
File "pyfantom.py", line 83, in <module>
dll = ctypes.CDLL(libpath, RTLD_LAZY)
File
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py",
line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Frameworks/fantom.framework/fantom, 3): Symbol not
found: _IOBluetoothSDPServiceRecordGetRFCOMMChannelID
Referenced from: /Library/Frameworks/fantom.framework/fantom
Expected in:
/System/Library/Frameworks/IOBluetooth.framework/Versions/A/IOBluetooth
[/traceback]
--
https://mail.python.org/mailman/listinfo/python-list