[PyQt] Simple Examples for using SIP with PyQt5

Robert Kent rob at gulon.co.uk
Fri Aug 21 12:22:05 BST 2015


Just to answer my own question:

I was simply missing a linker flag (doh!), every thing is now working fine :)

I may well write up my mini-example as a tutorial somewhere to help others as it really is easy to create PyQt extensions when you know how!

Thanks for all the help and suggestions guys and thanks, as always, to Phil for his amazing work.

Cheers, Rob


> On 21 Aug 2015, at 11:44, Robert Kent <rob at gulon.co.uk> wrote:
> 
> Hi All,
> 
> So, as expected, I’m having issues with my generated library. To test my configuration I’ve made a very simple example that wraps a QLabel. This is built as a Library (.dylib) using QtCreator and I am able to link and use it from C++ (so hopefully that means the library is built correctly?!). However, when I build the python wrapper and attempt to import it I get missing symbols:
> 
> Traceback (most recent call last):
>   File "test_pymylabel.py", line 4, in <module>
>     from PyMyLabel import *
> ImportError: dlopen(/Users/rob/Documents/Qt5/PyMyLabel/PyMyLabel.so, 2): Symbol not found: __ZN10QArrayData11shared_nullE
>   Referenced from: /Users/rob/Documents/Qt5/PyMyLabel/PyMyLabel.so
>   Expected in: flat namespace
>  in /Users/rob/Documents/Qt5/PyMyLabel/PyMyLabel.so
> 
> I’m guessing I’ve failed in my configuration somewhere? If I import PyQt5 before attempting to import my module it till fails but on a different symbol:
> 
> Traceback (most recent call last):
>   File "test_pymylabel.py", line 4, in <module>
>     from PyMyLabel import *
> ImportError: dlopen(/Users/rob/Documents/Qt5/PyMyLabel/PyMyLabel.so, 2): Symbol not found: __ZN7MyLabel16staticMetaObjectE
>   Referenced from: /Users/rob/Documents/Qt5/PyMyLabel/PyMyLabel.so
>   Expected in: flat namespace
>  in /Users/rob/Documents/Qt5/PyMyLabel/PyMyLabel.so
> 
> I don’t know if anyone finds this suggestive of a common fault or can give me some pointers as to where to look for the issue. I’m more than willing to post any part of the example that might be useful for diagnosis (I just didn’t want to spam the list with code listings!).
> 
> Any help will be gratefully appreciated!
> 
> Thanks, Rob
> 
>> On 20 Aug 2015, at 15:59, Robert Kent <rob at gulon.co.uk <mailto:rob at gulon.co.uk>> wrote:
>> 
>> Hi David,
>> 
>> Good suggestion as that’s what I was in the process of doing and its worked…sort of! I’ve now got something that cleanly compiles to an ‘.so’, but when I import it I get missing symbol errors. I imagine however that this is to do with the overly simplistic sip definition I was using to develop the build process.
>> 
>> Thanks very much for the help and patience, you may well hear from me again when I can’t get my function/method signatures in my sip definition right! :)
>> 
>> Cheers, Rob
>> 
>>> On 20 Aug 2015, at 15:45, David Boddie <david at boddie.org.uk <mailto:david at boddie.org.uk>> wrote:
>>> 
>>> On Thu Aug 20 14:53:46 BST 2015, Robert Kent wrote:
>>> 
>>>> I have actually managed to run the sip command successfully and auto-generated
>>>> the necessary code, my issue is actually with creating a working configure.py
>>>> and hence a Makefile. The examples refer to “pyqtconfig” which used to provide
>>>> a range of Makefile classes which seemed to fill in all the details regarding
>>>> include and library directories and compiler/linker options in general for the
>>>> Qt framework and sip. Any help on what the necessary options are or how to
>>>> obtain them would be hugely appreciated.
>>> 
>>> It might be worthwhile looking at the configuration script for the Python
>>> bindings to QScintilla:
>>> 
>>> https://riverbankcomputing.com/software/qscintilla/intro <https://riverbankcomputing.com/software/qscintilla/intro>
>>> 
>>> Look in the Python/configure.py file for some code that figures out the PyQt and
>>> Qt configurations. It looks like it was written to be used as a template for
>>> other projects, too.
>>> 
>>> David
>>> _______________________________________________
>>> PyQt mailing list    PyQt at riverbankcomputing.com <mailto:PyQt at riverbankcomputing.com>
>>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt <https://www.riverbankcomputing.com/mailman/listinfo/pyqt>
>> 
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com <mailto:PyQt at riverbankcomputing.com>
>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt <https://www.riverbankcomputing.com/mailman/listinfo/pyqt>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150821/d4e89f33/attachment.html>


More information about the PyQt mailing list