mingw-cross-env-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Mingw-cross-env-list] Qt5 static linking problem


From: Martin Lambers
Subject: Re: [Mingw-cross-env-list] Qt5 static linking problem
Date: Sat, 27 Apr 2013 02:47:31 +0200

On Fri, 26 Apr 2013 00:59:53 +0200, Mark Brand wrote:
> On Thursday 25 April 2013 22:30:10 Martin Lambers wrote:
> > I'm moving from Qt4 to Qt5, and I hit the following problem:
> > 
> > The application builds and links fine, but when running (under
> > Wine), it exits with the following message:
> > -----
> > Failed to load platform plugin "windows". Available platforms are:
> > 
> > 
> > abnormal program termination
> > -----
> > 
> > Note that I don't use qmake. I detect the Qt5Widgets module with
> > pkg-config, and this drags in Qt5Gui and Qt5Core.
> > 
> > Google has lots of hits for this error message, but nothing
> > conclusive.
> > 
> 
> Qt 5 uses platform plugins. When linking statically, the usual
> procedure [1] for linking to static plugins is necessary. However,
> qmake does this automatically for the platform plugin. It adds a
> special source file to the project and links to the static plugin
> library. If you are using pkg-config instead of qmake, you will have
> to do it explicitly. You might want to look at how qmake sets up a
> simple project.
> 
> Mark
> 
> [1]
> http://qt-project.org/doc/qt-5.0/qtcore/plugins-howto.html#static-plugins

Hi Mark,

thank you very much for your hints, I have it working now. I have to
say that it could have been better documented by the Qt project, though.

In case anyone has the same troubles, I did the following, in addition
to tracking the API changes between Qt4 and Qt5:

- With pkg-config, detect Qt5Widgets instead of the old QtGui.
  This gives you libqt_LIBS and libqt_CFLAGS (for example).
- You need the QWindowsIntegrationPlugin and the AccessibleFactory
  plugin. To link against them statically, you have to add them to
  libqt_LIBS: 
  libqt_plugin_L="`$PKG_CONFIG --libs-only-L Qt5Core
        | $SED -e 's/ //g'`/../plugins"
  libqt_LIBS="$libqt_plugin_L/platforms -lqwindows
        $libqt_plugin_L/accessible -lqtaccessiblewidgets
        $libqt_LIBS"
- You need to compile with QT_STATICPLUGIN defined:
  libqt_CFLAGS="$libqt_CFLAGS -DQT_STATICPLUGIN"
- You need to import the plugins in your code:
  Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
  Q_IMPORT_PLUGIN(AccessibleFactory)

Notes:
- Finding the correct names for Q_IMPORT_PLUGIN() was a lot of
  guessing as there does not seem to be any list.
- My project also builds without AccessibleFactory, but then gives a
  ton of runtime warnings.

Regards,
Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]