How to disable RTLD_NOW for Python 2.7.x dlopen() in Mac OS X Mavericks?
nad at acm.org
Thu Nov 14 04:44:44 CET 2013
In article <c9bc3283-e895-4d9f-a749-fc35497a875e at googlegroups.com>,
tcwan99 at gmail.com wrote:
> 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
> 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
> Enclosed is a snippet of the code and the Traceback. Is there a way to force
> RTLD_NOW off?
I'm not very familiar with ctypes internals but it looks like
sys.setdlopenflags is not intended to have an influence on ctypes; rather, it
conditions the Python interpreter's use of dlopen to load shared Python
modules. For ctypes itself, it looks like it unconditionally sets RTLD_NOW
when calling dlopen and probably with good reason:
Sorry, I don't have a suggestion for you, assuming you want to just try to
ignore the error, other than perhaps running an older version of OS X in a VM
nad at acm.org
More information about the Python-list