[PyQt] Passing image using SIP

Jarosław Białas jarekbialas.bialy at gmail.com
Wed Jun 22 10:21:10 BST 2011

On 21.06.2011 20:02, David Boddie wrote:
> On Mon Jun 20 23:46:27 BST 2011, Jarosław Białas wrote:
>> I wanted to create code fragment that will pass an object containg image
>> or pointer to this object from Python to C++ function.
>> I tried to create function:
>> void loadImage(QImage* image);
>> Then I created sip file, and after compiling and linking everything
>> looks fine until I tried to import shared library in python:
>> ImportError: ./test.so: undefined symbol: _ZTI6QImage
> It looks like QtGui wasn't linked in when your shared library was created.
> How was the linker run? What command line options and arguments were passed
> to it?
> David
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

You were absolutely right. QtGui wasn't linked. But SIP still throw an 
error - sip: Q_PID is undefined. So i add SIP platform tag -t WS_X11.
It wasn't working too - sip: QFileIconProvider is undefined, but after 
extra modification:

$ /usr/bin/sip -c . -I/usr/share/sip -t WS_X11 -t Qt_4_7_2  -b hello.sbf 
$ g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 
-I/usr/include/QtGui -I/usr/include/QtCore -o siphellocmodule.o 
$ g++ -c -pipe -fPIC -O2 -Wall -W -DNDEBUG -I. -I/usr/include/python2.7 
-I/usr/include/QtGui -I/usr/include/QtCore -o siphellohello.o 
$ g++ -Wl,--hash-style=gnu -Wl,--as-needed -shared 
-Wl,--version-script=hello.exp -o hello.so siphellocmodule.o 

I've got: undefined symbol: _ZN5hello9loadImageEP6QImage.I found out 
that I've only declared loadImage. So after all it works fine. Thank you 
for help.

More information about the PyQt mailing list