How can I include QtQuick in a static build?



  • (this is on windows with mingw, for linux i link dynamically)

    I'm trying to create a standalone binary for my application.

    I've managed to build a static version of qt using a powershell script: http://qt-project.org/forums/viewthread/35655

    I've managed to add my own qml to the binary using a qrc file.

    So currently this is my deployment directory:

    @Deployment
    myapp.exe
    QtQuick
    //copied from C:\Qt\Qt5.2.1\5.2.1\mingw48_32\qml
    QtQuick.2
    qmldir@

    If I remove any of these files, all I see is a white window

    How can I use qmake/qrc to include these files as well?

    EDIT: Here is my project file:

    @TARGET = nmgui
    QT += core gui qml quick svg
    CONFIG += static staticlib warn_on
    QTPLUGIN += qsvg qtquick2plugin

    QMAKE_CXXFLAGS += -std=c++11
    -Wall -Werror -Wextra
    -pedantic-errors -Wwrite-strings
    -Woverloaded-virtual -Wredundant-decls
    -Wold-style-cast

    The .cpp file which was generated for your project. Feel free to hack it.

    SOURCES += main.cpp
    ....
    document.cpp

    HEADERS +=
    moduleq.hpp
    ...
    document.hpp

    INCLUDEPATH = . ..

    win32{
    Debug {
    LIBS += -L../nmlib/debug
    PRE_TARGETDEPS += ../nmlib/debug/libnmlib.a
    }
    Release {
    LIBS += -L../nmlib/release
    PRE_TARGETDEPS += ../nmlib/release/libnmlib.a
    }
    } else {
    LIBS += -L../nmlib
    PRE_TARGETDEPS += ../nmlib/libnmlib.a
    }
    LIBS += -lnmlib

    Please do not modify the following two lines. Required for deployment.

    include(qtquick2applicationviewer/qtquick2applicationviewer.pri)
    qtcAddDeployment()

    RESOURCES +=
    nmgui.qrc@



  • Same problem here using latest 5.3.0 RC on MinGW 4.8

    I still have no solution but looks like Qt always prefers to load the dynamic version of the dll if it's able to find.
    The only way I've found to disable dynamic loading is

    @
    QQmlApplicationEngine engine;
    engine.setImportPathList(QStringList());
    @

    but even in that case I still get

    @
    module "QtQuick" is not installed
    @

    Qmake is correctly generating *_plugin_import.cpp

    @
    // This file is autogenerated by qmake. It imports static plugin classes for
    // static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables.
    #include <QtPlugin>
    Q_IMPORT_PLUGIN(AccessibleQuickFactory)
    Q_IMPORT_PLUGIN(QtQuick2Plugin)
    Q_IMPORT_PLUGIN(QTcpServerConnection)
    Q_IMPORT_PLUGIN(QGenericEnginePlugin)
    Q_IMPORT_PLUGIN(QNativeWifiEnginePlugin)
    Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
    Q_IMPORT_PLUGIN(QDDSPlugin)
    Q_IMPORT_PLUGIN(QICNSPlugin)
    Q_IMPORT_PLUGIN(QICOPlugin)
    Q_IMPORT_PLUGIN(QJp2Plugin)
    Q_IMPORT_PLUGIN(QMngPlugin)
    Q_IMPORT_PLUGIN(QTgaPlugin)
    Q_IMPORT_PLUGIN(QTiffPlugin)
    Q_IMPORT_PLUGIN(QWbmpPlugin)
    Q_IMPORT_PLUGIN(QWebpPlugin)
    @

    and *_qml_plugin_import.cpp

    @
    // This file is autogenerated by qmake. It imports static plugin classes for
    // static plugins used by QML imports.
    #include <QtPlugin>
    Q_IMPORT_PLUGIN(QtQuick2Plugin)
    Q_IMPORT_PLUGIN(QtQuickControlsPlugin)
    Q_IMPORT_PLUGIN(QtQuickLayoutsPlugin)
    Q_IMPORT_PLUGIN(QtQuick2DialogsPlugin)
    Q_IMPORT_PLUGIN(QtQuick2WindowPlugin)
    Q_IMPORT_PLUGIN(QtQuick2DialogsPrivatePlugin)
    Q_IMPORT_PLUGIN(QmlFolderListModelPlugin)
    Q_IMPORT_PLUGIN(QmlSettingsPlugin)
    Q_IMPORT_PLUGIN(QtQuick2PrivateWidgetsPlugin)
    @

    As a last trial I've included the Q_IMPORT_PLUGIN(*) to main (will plugins get a "double registration" now?) and I add explicit registerTypes i still get errors on random components not present/registered.

    @
    #ifdef STATIC_BUILD
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QWindowsIntegrationPlugin().instance())->registerTypes("windows");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2Plugin().instance())->registerTypes("QtQuick");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2PrivateWidgetsPlugin().instance())->registerTypes("QtQuick.PrivateWidgets");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls.Styles");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickControlsPlugin().instance())->registerTypes("QtQuick.Controls.Private");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2DialogsPlugin().instance())->registerTypes("QtQuick.Dialogs");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2DialogsPrivatePlugin().instance())->registerTypes("QtQuick.Dialogs.Private");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuickLayoutsPlugin().instance())->registerTypes("QtQuick.Layouts");
    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_QtQuick2WindowPlugin().instance())->registerTypes("QtQuick.Window");
    #endif
    @

    I've seen different QTBUGs on the topic (static linking of QML Plugins) and even if some have been closed it looks like static linking QML is still not working/supported on desktop.



  • I have the same problem.
    But i solved with Quick 2.2 without QtQuick.Controlc 1.1. Peaple, help please. Static building of qml app is already wasted so much time!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.