On Monday 19 February 2007 15:34, Phil Thompson wrote: > On Monday 19 February 2007 3:15 pm, Paul Giannaros wrote: > > On Monday 19 February 2007 13:34, Phil Thompson wrote: > > > On Monday 19 February 2007 12:55 pm, Paul Giannaros wrote: > > > > Hi there, > > > > I have wrapped key bits of Kate's interface (as documented at > > > > http://developer.kde.org/documentation/library/3.5-api/kdebase-apidoc > > > >s/ ka te /html/) with SIP. Firstly, thanks for SIP -- along with good > > > > documentation, ease of use, and Qt/KDE support it was a piece of > > > > cake. However, my intention is to use that library from within a C++ > > > > Kate Plugin. The plugin embeds Python and (so far) just attempts to > > > > import the SIP-created module. Doing so gives an ImportError, > > > > however, which I do not get if I just import the module from the > > > > interactive > > > > interpreter. > > > > > > > > The error is: > > > > ImportError: /usr/lib/python2.5/site-packages/sip.so: undefined > > > > symbol: _Py_ZeroStruct. > > > > > > > > Both my C++ plugin and my SIP extension link to python (the SIP > > > > extension does because if I don't I get a 'PyCObject_Type' undefined > > > > error when trying to import it). > > > > > > > > Another interesting thing is that If I isolate the importing code > > > > from the Kate plugin with a simple application, it imports fine. > > > > > > > > Any ideas what's going wrong? > > > > > > There are a couple of things your plugin needs to do (for a Qt4 example > > > see the new Designer plugin in current PyQt4 snaphots). > > > > > > You need to make sure the Python shared library is loaded and that it > > > exports all of its symbols. > > > > I'm currently just linking to it on the command line (via -lpython2.5) > > when I link my library. I see from designer/pluginloader.cpp that you use > > QLibrary::load as well? I tried doing that but setLoadHints isn't > > available here (Qt 3.3) and just calling load() causes the same error. > > There is a way to do it - but I can't remember what it is at the moment. > Have a look through the PyKDE source code - it will be in there somewhere - > related to loading KParts. >
Couldn't find how to do it in PyKDE (tried all manner of searches for QLibrary/KLibrary) so I resorted to looking at Qt 4.3's load() call. It just passes an extra flag to dlopen, so I got rid of QLibrary and did the dlopen call myself. Not exactly cross-platform, but it seems to work :-). Thanks > > > You should also make sure you link against the Python shared library > > > and not the static one. > > > > I can verify that I'm linking to the shared library via `ldd > > mykateplugin.so`: .... > > libpython2.5.so.1.0 => /usr/lib/libpython2.5.so.1.0 (0xb7d16000 > > .... > > Phil > > _______________________________________________ > PyKDE mailing list [email protected] > http://mats.imk.fraunhofer.de/mailman/listinfo/pykde _______________________________________________ PyKDE mailing list [email protected] http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
