[PyQt] Linking Qt statically into a project using embedded Python
rasky at develer.com
Wed Feb 4 17:58:09 GMT 2009
On 2/4/2009 4:42 PM, Ulrich Berning wrote:
> George Goussard wrote:
>> My project that I am currently working on is a cross-platform C++
>> project. On Linux 32-bit/64-bit I have the constraint that I MUST link
>> Qt (4.3.3) in statically with the project. This is a given and cannot
>> be compromised. I have successfully embedded Python into our
>> application and with this facility I can run external Python *.py
>> files. With the help of Sip/PyQt used in these *.py files I can route
>> the output to a nice window inside my Qt application etc. etc.
>> But,....the problem is that it only works if I link Qt in dynamically
>> to my application.
>> The reason(I think – when I link dynamically to Qt) is because my
>> application loads the Qt *.so file dynamically when I startup the
>> application. Then when the application runs an external *.py file and
>> it has the line “from PyQt import QtCore” then I suppose that it sees
>> the *.so is already loaded and uses it. Now my question: How can I
>> either get the Python mechanism or Sip/PyQt to rather use the
>> statically linked in Qt with my project?
>> Currently, if I link Qt statically into my application and run the
>> *.py files I get some strange Qt message on the command line and then
>> it crashes.
> The only way to do this, is to have everything statically linked:
> - Build a static Python library
> - Build a static SIP library
> - Build static PyQt libraries
> Use PyImport_ExtendInittab() to declare the module initialization
> functions for SIP and all PyQt modules you need in your application.
> This must be done before you initialize the python interpreter with
It should also work if you recompile a single dynamic library
(python.so) with PyQt and SIP included within as builting modules.
More information about the PyQt