[PyKDE] Importing a generated library
Ulrich Berning
ulrich.berning at desys.de
Tue Jan 27 13:34:01 GMT 2004
Jahn Otto Næsgaard Andersen schrieb:
>Hi,
>
>I have sip'ed a C++ class and compiled the resulting files with
>
>g++ -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -pipe -fPIC -O2 -Wall -W
>-D_REENTRANT -c -I.. -I. -I/usr/local/include/python2.3
>-I/home/jotto/work/hololib/src sipHoloLibcmodule.cpp
>
>g++ -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -pipe -fPIC -O2 -Wall -W
>-D_REENTRANT -c -I.. -I. -I/usr/local/include/python2.3
>-I/home/jotto/work/hololib/src sipHoloLibBird.cpp
>
>and then linked everything together with
>
>g++ -shared -Wl,-rpath,/usr/lib/qt-x11-free-3.2.3/lib
>-L/usr/local/lib/python2.3/site-packages -L/usr/local/lib/vtk -lvtkCommon
>-lvtkRendering -lvtkGraphics -lvtkHybrid -L/usr/lib/qt-x11-free-3.2.3/lib
>-lqt-mt -o hololib.so *.o /home/jotto/work/hololib/build/*.o
>
>
>The .o files in /home/jotto/work/hololib/build are C++ .o files that I
>don't need to access directly from python. Note that I am dynamically
>linking in qt and VTK.
>
>It compiles and links without errors, but when I copy the hololib.so to
>python's site-packages, I get the following error when I try to import:
>
>
>
>
>>>>from hololib import *
>>>>
>>>>
>Traceback (most recent call last):
> File "<stdin>", line 1, in ?
>ImportError: dynamic module does not define init function (inithololib)
>
>
>I try to check the defined symbols in hololib.so with nm:
>
>jotto at holodeck(~/work/py_hololib/sipcode)$ nm hololib.so | grep initHol
>000172a0 T initHoloLib
>0002ad28 d _ZZ11initHoloLibE7methods
>
>It seems to me like initHoloLib is defined.
>
>I'm using RedHat 8.0, Python 2.3, SIP 4.0rc2 and gcc 3.2.
>
>Any ideas?
>
>
>
>Btw, thank you for all the help I have got so far! I think I'm close to
>the goal now :-)
>
>
>Jahn Otto
>
>_______________________________________________
>PyKDE mailing list PyKDE at mats.imk.fraunhofer.de
>http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
>
>
The exceptions message tells you exactly what is going wrong.
Your init function is initHoloLib, but you import hololib which expects
an inithololib function.
Either your module name should be HoloLib.so (change the link target to
-o HoloLib.so) or your init function should be inithololib (change
%Module HoloLib to %Module hololib in your sip file).
Ulli
More information about the PyQt
mailing list