On segunda-feira, 2 de abril de 2012 10.07.54, Thiago Macieira wrote:
> On segunda-feira, 2 de abril de 2012 15.49.25, Nikos Chantziaras wrote:
> > On 02/04/12 15:38, Thiago Macieira wrote:
> > > On segunda-feira, 2 de abril de 2012 15.17.31, Nikos Chantziaras wrote:
> > >> Hello.
> > >> 
> > >> I have a use case where linking an executable statically against Qt
> > >> makes sense.  However, the resulting binary fails to use KDE's current
> > >> widget style (like Oxygen).  Is this even possible with binaries that
> > >> link-in Qt statically?
> > > 
> > > No. It's completely impossible.
> > 
> > Ah, too bad.  Thanks for the quick response.
> > 
> > Purely out of curiosity though, why is that?
> 
> Because of this:
> 
> $ ldd $KDEDIR/lib/kde4/plugins/styles/oxygen.so| grep Qt
>         libQtDBus.so.4 => /home/thiago/obj/qt/qt-4.8-
> release/lib/libQtDBus.so.4 (0x00007f500ef32000)
>         libQtCore.so.4 => /home/thiago/obj/qt/qt-4.8-
> release/lib/libQtCore.so.4 (0x00007f500ea46000)
>         libQtGui.so.4 =>
> /home/thiago/obj/qt/qt-4.8-release/lib/libQtGui.so.4 (0x00007f500dcc4000)
>         libQtXml.so.4 =>
> /home/thiago/obj/qt/qt-4.8-release/lib/libQtXml.so.4 (0x00007f500cd18000)
>         libQtNetwork.so.4 => /home/thiago/obj/qt/qt-4.8-
> release/lib/libQtNetwork.so.4 (0x00007f500c6a8000)
>         libQtSvg.so.4 =>
> /home/thiago/obj/qt/qt-4.8-release/lib/libQtSvg.so.4 (0x00007f500c44e000)
> 
> If you can make the Oxygen plugin not link to Qt, then it can be loaded.

Uh.. I realise I didn't explain why.

Qt plugins cannot be loaded *because* they link to Qt. The plugin requires 
functions and other symbols that are present in the Qt libraries. However, the 
Qt libraries were already linked into the application. And, worse, since it 
was a static link, only what you used of Qt got linked.

So there are broad swathes of Qt missing. And the ones that are present are 
unusable because they were statically linked.

Loading the dynamic Qt would not work either because some symbols might 
resolve into the application, some others to the libs you loaded. Really bad 
idea.

For that reason, the QPluginLoader class in a static Qt does load anything. It 
operates only on the "static plugins" -- that is, plugin code compiled as a 
static lib and linked into the application.

If you want the Oxygen style in your app, there's a workaround: use the Gtk 
style and make Gtk use Oxygen. The Oxygen-Gtk plugin has no Qt dependency:

$ ldd /usr/lib64/gtk-2.0/2.10.0/engines/liboxygen-gtk.so | grep -c Qt
0

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Attachment: signature.asc
Description: This is a digitally signed message part.

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Reply via email to