xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
10.14k stars 782 forks source link

Qt deploy with MinGW is not working in release mode #5377

Closed yh-sb closed 3 months ago

yh-sb commented 3 months ago

Xmake Version

2.9.3

Operating System Version and Architecture

Windows 11 23H2 22631.3880

Describe Bug

xmake Qt install is failing using release build type with MinGW profile.

To reproduce, setup simple Qt project using the xmake.lua below:

xmake create -t qt.widgetapp qt-app
cd qt-app

# Copy-paste the xmake.lua attached below

xmake f -p mingw
xmake
xmake install -o build/install -v
# See the error output in log below

xmake.lua:

add_rules("mode.debug", "mode.release")

add_requires("qt6core 6.5.3", "qt6gui 6.5.3", "qt6widgets 6.5.3")

target("qt-app")
    add_rules("qt.widgetapp")
    add_packages("qt6core", "qt6gui", "qt6widgets")
    add_frameworks("QtCore", "QtGui", "QtWidgets")
    add_files(
        "src/main.cpp",
        "src/mainwindow.cpp",
        "src/mainwindow.h",
        "src/mainwindow.ui"
    )

Error output:

PS D:\qt-app> xmake install -o build/install -v
installing qt-app ..
installing qt-app to build/install ..
> copy build\mingw\x86_64\release\qt-app.exe to build\install\bin
C:\Users\Y\AppData\Local\.xmake\packages\q\qt6base\6.5.3\eab1a6d6b5364cf1afaba7d533645048\bin\windeployqt.exe --force --verbose=1 --release build\install\bin\qt-app.exe
D:\qt-app\build\install\bin\qt-app.exe 64 bit, release executable
Direct dependencies: Qt6Core Qt6Gui Qt6Widgets
All dependencies   : Qt6Core Qt6Gui Qt6Widgets
To be deployed     : Qt6Core Qt6Gui Qt6Widgets
Unable to find the platform plugin.
error: install failed, execv(C:\Users\Y\AppData\Local\.xmake\packages\q\qt6base\6.5.3\eab1a6d6b5364cf1afaba7d533645048\bin\windeployqt.exe --force --verbose=1 --release build\install\bin\qt-app.exe) failed(1)

Expected Behavior

xmake install should work OK in release build type too.

Project Configuration

Profile: mingw.

jingkaimori commented 3 months ago

How is your qt installed? Name suffix of debug version is differ between qt installed from aqt and qt installed from official installer. Qt installed from aqt (qt in xrepo is provided by aqt) has Qtxxx.dll only, but the dll is debug version; Qt installed from official installer has both Qtxxx.dll and Qtxxxd.dll.

yh-sb commented 3 months ago

I'm using Qt installed by xmake from xrepo. Specified in attached xmake.lua.

As far as I know, there are no debug suffixes in MinGW Qt, but I doubt it.

SirLynix commented 3 months ago

aqt is able to install debug Qt binaries, this is handled by qt packages

waruqi commented 3 months ago

try this patch? https://github.com/xmake-io/xmake/commit/58321e316751cafb3ceb134dbf81a8703e5ea85b

yh-sb commented 3 months ago

try this patch? 58321e3

It doesn't help. The same error. The same windeployqt options.

waruqi commented 3 months ago

try this patch? 58321e3

It doesn't help. The same error. The same windeployqt options.

I checkout dev branch and it works for me. xmake update -s dev

$ xmake install -o build/install -v
installing qt-app ..
installing qt-app to build\install ..
> copy build\mingw\x86_64\release\qt-app.exe to build\install\bin
C:\Users\wangrunqing\AppData\Local\.xmake\packages\q\qt6base\6.5.3\eab1a6d6b5364cf1afaba7d533645048\bin\windeployqt.exe --force --verbose=1 build\install\bin\qt-app.exe
C:\Users\wangrunqing\Downloads\testqt2\build\install\bin\qt-app.exe 64 bit, release executable
Adding Qt6Network for qtuiotouchplugin.dll
Adding Qt6Svg for qsvgicon.dll
Direct dependencies: Qt6Core Qt6Gui Qt6Widgets
All dependencies   : Qt6Core Qt6Gui Qt6Widgets
To be deployed     : Qt6Core Qt6Gui Qt6Network Qt6Svg Qt6Widgets
Updating Qt6Core.dll.
Updating Qt6Gui.dll.
Updating Qt6Network.dll.
Updating Qt6Svg.dll.
Updating Qt6Widgets.dll.
Updating opengl32sw.dll.
Updating D3Dcompiler_47.dll.
Updating libgcc_s_seh-1.dll.
Updating libstdc++-6.dll.
Updating libwinpthread-1.dll.
Updating qtuiotouchplugin.dll.
Updating qsvgicon.dll.
Updating qgif.dll.
Updating qico.dll.
Updating qjpeg.dll.
Updating qsvg.dll.
Updating qnetworklistmanager.dll.
Updating qwindows.dll.
Updating qwindowsvistastyle.dll.
Updating qcertonlybackend.dll.
Updating qopensslbackend.dll.
Updating qschannelbackend.dll.
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_fa.qm...
Creating qt_fi.qm...
Creating qt_fr.qm...
Creating qt_gd.qm...
Creating qt_he.qm...
Creating qt_hr.qm...
Creating qt_hu.qm...
Creating qt_it.qm...
Creating qt_ja.qm...
Creating qt_ko.qm...
Creating qt_lv.qm...
Creating qt_nl.qm...
Creating qt_nn.qm...
Creating qt_pl.qm...
Creating qt_pt_BR.qm...
Creating qt_ru.qm...
Creating qt_sk.qm...
Creating qt_tr.qm...
Creating qt_uk.qm...
Creating qt_zh_CN.qm...
Creating qt_zh_TW.qm...
install ok!
yh-sb commented 3 months ago

xmake update -s dev fixed Qt deployment in release mode. But now it all the time release.

Even in debug mode windeployqt is called like in release. Maybe it's common practice for MinGW Qt?

waruqi commented 3 months ago

xmake update -s dev fixed Qt deployment in release mode. But now it all the time release.

Even in debug mode windeployqt is called like in release. Maybe it's common practice for MinGW Qt?

Shouldn't windeployqt and xmake install just be used for releases? If you want to debug a qt app, you can just run xmake run -d to launch debugger to debug it.

yh-sb commented 3 months ago

Maybe you are right. Let's close this, since it's already fixed. Thank you!