[PyQt] Deploying PyQt4 on Linux

Andreas Pakulat apaku at gmx.de
Thu Jun 25 10:30:13 BST 2009

On 25.06.09 11:04:30, Hans-Peter Jansen wrote:
> Am Donnerstag, 25. Juni 2009 schrieb ion vasilief:
> > Hello everybody,
> >
> > I'm trying to deploy an application ("my_app")
> > that uses Qt, Python, PyQt4 and SIP on Linux in a distribution
> > independent way (meaning that even if there are other default versions
> > of these libraries installed on the system, my_app will load at run
> > time the symbols from the libraries I have built it against).
> > My idea was to deploy all the necesarry dependencies in the
> > /usr/local/my_app/lib folder.
> >
> > Therefore
> > I have compiled Qt 4.5.1 and Python 2.6 with the
> > --prefix=/usr/local/my_app option. After that I have built SIP and
> > PyQt4 using Qt/Python versions previousely built. Finally I have
> > compiled my application against all these libraries. At run time, PyQt4
> > still loads the default Qt 4.5.0 installed on the system (in /usr/lib),
> > instead of the Qt 4.5.1 version from the /usr/local/my_app/lib folder.
> > The only solution I have found is to modify the QTDIR environement
> > variable, but I don't want to mess with that when I deploy my
> > application.
> >
> > My question: is there a way to force PyQt4 to load the symbols from the
> > Qt version it was built against?
> That's gonna be tough. You WILL have to fiddle with QTDIR and most probably 
> with LD_LIBRARY_PATH, but just do it in a shell wrapper.

No need for that, especially QTDIR is completely unknown to Qt4. That
variable simply doesn't exist anymore. You can adjust LD_LIBRARY_PATH to
poin to the Qt library, however you can also manage to do it without. Use
the RPATH and RUNPATH stuff when linking PyQt to your Qt, you'll have to
adjust the PyQt buildsystem for that I think and you probably want to make
sure that you use relative paths so your app can be installed anywhere on
the target system.

> You have to take care of dependant libs of ALL components, and need to
> test it on all targeted distributions.

deps are not a big deal with Qt as it ships most of its deps itself and can
also compile them in statically without having the libraries themselves
being static libs. The only dep would be X11 and that should be a
no-brainer usually.

The other option would be building Qt as static libs and let PyQt use that,
then you don't have to go through any of the hoops.


You fill a much-needed gap.

More information about the PyQt mailing list