[Development] Static build with QtQuick in Qt5.1.0
Mediator Software
ian at mediator-software.com
Mon May 20 12:53:43 CEST 2013
Hi,
The issue with static builds and QtQuick are many, apart from the issues
mentioned in the bug report (ie. need to statically 'load' plugin, need to
register plugin types), there is an additional problem that the static
initialiser(s) used to set up the QML types are optimised out by the linker (on
iOS at least). The workaround (on iOS) is to force the linker to load all
symbols from the QtQuick plugin by using the following linker option:
-force_load libQt5Quick.a
This solves the issue where basic QML types are missing (eg. colour names).
The other missing piece (which isn't mentioned in the bug report), is that you
need to call initializeEngine() on each plugin, as some plugins do
initialization there, which is not called when the plugin is linked/'loaded'
statically.
With these techniques, I've managed to build QmlScene statically with all
plugins supplied with Qt5.0/5.1, and run it on iOS. Everything works as expected
once you 'load' the plugin(s), register their types and initialise them. QML
based plugins (ie. not C++) will need to be put in the path where QML expects to
find them (easiest is to use the executable path, as no code changes are required).
This is a very manual process, so it would be nice if there was something that
generated the initialisation code (a macro even?) for QML plugins when building
them statically (although of course they're not 'plugins' at that point...).
HTH
More information about the Development
mailing list