[PyQt] SIP Problem dynamic loading in wrapped library
Jens Thoms Toerring
jt at toerring.de
Thu Mar 31 01:31:57 BST 2011
On Thu, Mar 31, 2011 at 01:24:44AM +0200, David Boddie wrote:
> On Wed, 30 Mar 2011 23:07:07 +0200, Jens Thoms Toerring wrote:
> > Since with the QLibrary class there doesn't seem to be a
> > possibility to get at the error messages from the dynamic linker
> > I replaced the QLibrary load() method calls with a dlopen() call.
> > This also fails and dlerror() tells me that when loading the
> > plugin some symbols are undefined. This seems strange because
> > it works in the case of a C++ program linked against the library
> > and, as checks with tools like 'nm' show, those symbols are
> > definitely defined in the wrapped C++ library (i.e. the one that
> > tries to load the plugin).
> > I have no good idea at the moment about the reasons for this
> > problem. Has anybody experienced a similar situation and per-
> > haps has found a work-around (or at least an explanation for
> > what is happening)?
> Just a suggestion: you might want to set the ExportExternalSymbolsHint
> load hint using the setLoadHints() method of your QLibrary instance.
Thank you very much for your tip. Unfortunately I already tried
that but without success:-( As far as I understand it 'Export-
ExternalSymbolsHint' tells the dynmaic loader that the symbols
of the library just being loaded are to be exported to libraries
loaded later on by that library (basically what RTLD_GLOBAL is
under UNIX), isn't it? If that's the case then the failure to
ectify things by setting this flag isn't too surprising since
the problem appears when the "last" library gets loaded, i.e.
the one relying on libraries previously loaded. It then would
be those libraries that would need to be loaded with this flag,
but I can't influence that, since the sequence is (as far as I
1) the import statement in the Python script loads the SIP
generated wrapper library
2) the wrapper library loads the "main" C++ library
So, in my (not unlikely to be wrong) understanding those are
the libraries needing the 'ExportExternalSymbolsHint' flag
since the problem seems to appear when then the C++ library
tries to dynamically load the plugin libraries.
Another point is that the problem is the same when using
dlopen() instead (that's what actually gave a meaningful
error message). So my gut feeling is that there's something
going on "upstream" that keeps the plugin libraries from
The thing to do is probably to write a very simple test set
of libraries and check what happens with them and, if the
problem persists, to post them here;-)
Thank you and best regards, Jens
\ Jens Thoms Toerring ________ jt at toerring.de
More information about the PyQt