“module QtQuick is not installed” error in Release

2019-06-05 00:15发布

问题:

I have a simple Qt 5.11 x64 project, MSVC 2017 compiler, with default build settings created by Qt Creator 4.7.

It works fine but when I added windeployqt for copying all Qt dlls in Release build I get error (running from Qt Creator)

QQmlApplicationEngine failed to load component
qrc:/qml/main.qml:1 module "QtQuick" is not installed

QML file has

import QtQuick 2.7

.pro

QT += quick widgets xml
CONFIG += c++11

CONFIG += precompile_header
PRECOMPILED_HEADER = stdafx.h

CONFIG -=  embed_manifest_exe
RC_FILE = app-uac.rc


DEFINES += QT_DEPRECATED_WARNINGS

DESTDIR=bin

SOURCES += main.cpp \
    ..........

RESOURCES += qml.qrc \
    img.qrc \
    font.qrc

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

HEADERS += \
    .........
    stdafx.h

OTHER_FILES += \
    app-uac.exe.manifest \
    app-uac.rc \
    app_info.xml

LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.17134.0/um/x64/" -lUser32 -lAdvAPI32

TARGET_CUSTOM_EXT = .exe

CONFIG(release, debug|release) {
    DEPLOY_COMMAND = $$[QT_INSTALL_BINS]/windeployqt --release --compiler-runtime

    DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/$${DESTDIR}/$${TARGET}$${TARGET_CUSTOM_EXT}))

    QMAKE_POST_LINK += $${DEPLOY_COMMAND} $${DEPLOY_TARGET}
}

windeployqt output

    C:/Qt/Qt5.11/5.11.1/msvc2017_64/bin/windeployqt --release --compiler-runtime C:\Users\.......-Release\bin\App.exe
C:\Users\.....-Release\bin\App.exe 64 bit, release executable [QML]
Adding Qt5Svg for qsvgicon.dll
Direct dependencies: Qt5Core Qt5Gui Qt5Qml Qt5Quick Qt5Widgets Qt5Xml
All dependencies   : Qt5Core Qt5Gui Qt5Network Qt5Qml Qt5Quick Qt5Widgets Qt5Xml
To be deployed     : Qt5Core Qt5Gui Qt5Network Qt5Qml Qt5Quick Qt5Svg Qt5Widgets Qt5Xml
Updating Qt5Core.dll.
Updating Qt5Gui.dll.
Updating Qt5Network.dll.
Updating Qt5Qml.dll.
Updating Qt5Quick.dll.
Updating Qt5Svg.dll.
Updating Qt5Widgets.dll.
Updating Qt5Xml.dll.
Updating libGLESV2.dll.
Updating libEGL.dll.
Updating d3dcompiler_47.dll.
Updating opengl32sw.dll.
Updating vc_redist.x64.exe.
Patching Qt5Core.dll...
Creating directory C:/.......-Release/bin/bearer.
Updating qgenericbearer.dll.
Creating directory C:/........-Release/bin/iconengines.
Updating qsvgicon.dll.
Creating directory C:/........-Release/bin/imageformats.
Updating qgif.dll.
Updating qicns.dll.
Updating qico.dll.
Updating qjpeg.dll.
Updating qsvg.dll.
Updating qtga.dll.
Updating qtiff.dll.
Updating qwbmp.dll.
Updating qwebp.dll.
Creating directory C:/.......-Release/bin/platforms.
Updating qwindows.dll.
Creating directory C:/......-Release/bin/qmltooling.
Updating qmldbg_debugger.dll.
Updating qmldbg_inspector.dll.
Updating qmldbg_local.dll.
Updating qmldbg_messages.dll.
Updating qmldbg_native.dll.
Updating qmldbg_nativedebugger.dll.
Updating qmldbg_profiler.dll.
Updating qmldbg_quickprofiler.dll.
Updating qmldbg_server.dll.
Updating qmldbg_tcp.dll.
Creating directory C:/Users/......-Release/bin/scenegraph.
Updating qsgd3d12backend.dll.
Creating directory C:/Users/.......-Release/bin/styles.
Updating qwindowsvistastyle.dll.
Creating C:\.......-Release\bin\translations...
Creating qt_ar.qm...
Creating qt_bg.qm...
Creating qt_ca.qm...
Creating qt_cs.qm...
Creating qt_da.qm...
Creating qt_de.qm...
Creating qt_en.qm...
Creating qt_es.qm...
Creating qt_fi.qm...
Creating qt_fr.qm...
Creating qt_gd.qm...
Creating qt_he.qm...
Creating qt_hu.qm...
Creating qt_it.qm...
Creating qt_ja.qm...
Creating qt_ko.qm...
Creating qt_lv.qm...
Creating qt_pl.qm...
Creating qt_ru.qm...
Creating qt_sk.qm...
Creating qt_uk.qm...

回答1:

Looks like it works with --qmldir parameter.

$$[QT_INSTALL_BINS]/windeployqt --release --compiler-runtime  --qmldir $$shell_quote($$shell_path($$PWD/qml))