How to create exe file on qt6
-
The 'windeployqt' does not include all necessary files needed for properly app starting, looking on my latest experience with using qt 6.8. I received a white window on app start. I was needed to manually check and add a few missing dlls and QML files into folder with 'exe' to run executable properly.
@Vitalii777 Thank you for the suggestion, could you please tell me which files and folders are missing so I can check and fix them?
-
@Xhuong Start your app from a terminal after setting QT_DEBUG_PLUGINS environment variable and check the output. See https://doc.qt.io/qt-6/debug.html
-
The messages are routed to the debug output, to see them you can use for example DebugView:
https://learn.microsoft.com/en-us/sysinternals/downloads/debugview -
@Vitalii777 Thank you for the suggestion, could you please tell me which files and folders are missing so I can check and fix them?
@Xhuong said in How to create exe file on qt6:
@Vitalii777 Thank you for the suggestion, could you please tell me which files and folders are missing so I can check and fix them?
I just tested '--qml' option and it does not work, the 'qml' folder is an empty after running
windeployqt.exe --qml "{full_path_to_exe}"
But I found information about using '--qmldir' in this article:
https://forum.qt.io/topic/73340/windeployqt-and-qml/2
Using '--qmldir' resolved issue without copying missing files manually so you can try to use this method.
Just one note that using '--qmldir' copied some files that are not used by mine test exe and it works without using these files, like a few folders in 'qml' folder - 'qml/QtMultimedia', 'qml/QtLocation', 'qml/QtPositioning', 'qml/QtQuick3D' etc. For example, before I manually copied just one 'qml/QtQuick' folder with just a few subfolders inside this folder and without '*.qml' files inside these subfolders and it works.
Also using '--qmldir' copied some additional dll files that are not used by app, like 'Qt6Multimedia.dll' and related 'ffmpeg' dlls, and a few other dlls. So the total package size is a bit large now (41 MB difference).
-
@Xhuong said in How to create exe file on qt6:
@Vitalii777 Thank you for the suggestion, could you please tell me which files and folders are missing so I can check and fix them?
I just tested '--qml' option and it does not work, the 'qml' folder is an empty after running
windeployqt.exe --qml "{full_path_to_exe}"
But I found information about using '--qmldir' in this article:
https://forum.qt.io/topic/73340/windeployqt-and-qml/2
Using '--qmldir' resolved issue without copying missing files manually so you can try to use this method.
Just one note that using '--qmldir' copied some files that are not used by mine test exe and it works without using these files, like a few folders in 'qml' folder - 'qml/QtMultimedia', 'qml/QtLocation', 'qml/QtPositioning', 'qml/QtQuick3D' etc. For example, before I manually copied just one 'qml/QtQuick' folder with just a few subfolders inside this folder and without '*.qml' files inside these subfolders and it works.
Also using '--qmldir' copied some additional dll files that are not used by app, like 'Qt6Multimedia.dll' and related 'ffmpeg' dlls, and a few other dlls. So the total package size is a bit large now (41 MB difference).
@Vitalii777 Thank you for this help. After following your suggestion, I was able to run the exe file when building it through the terminal (QT 6.8.3 MSVC 2022 64 bit), but I still cannot run the exe file directly. Why is that?
-
@Vitalii777 Thank you for this help. After following your suggestion, I was able to run the exe file when building it through the terminal (QT 6.8.3 MSVC 2022 64 bit), but I still cannot run the exe file directly. Why is that?
-
@Xhuong said in How to create exe file on qt6:
I was able to run the exe file
but I still cannot run the exe file directly
Given the first phrase in your post what does the second phrase mean?
-
@JonB Thanks for answering my question. I can only run exe file when i use terminal QT 6.8.3 MSVC 2022 64 bit as in the picture
So I want to know the reason why I can't run the exe file directly@Xhuong said in How to create exe file on qt6:
So I want to know the reason why I can't run the exe file directly
I wish you would say what you mean by this?! What does "run exe directly" mean to you other than exactly what you show? Are you talking about running it by having a shortcut on your desktop? Is that what you call "directly"?
Meanwhile, you are not "simply" running it from a terminal. You have opened a shell which says it is setting up its environment for Qt usage. So it's doing more than somewhere else. Does it run if you just open a terminal/Command Prompt which has nothing to do with Qt or vcvars.bat?
Do you want to run it somehow differently but still on your own development machine, or do you want to deploy it to an environment which does not itself already have Qt files?
-
@JonB Thanks for answering my question. I can only run exe file when i use terminal QT 6.8.3 MSVC 2022 64 bit as in the picture
So I want to know the reason why I can't run the exe file directly@Xhuong Did you try what @hskoglund suggested?
Most probably one mandatory plug-in cannot be loaded because of missing dependencies.
Or a DLL is missing in your deployed application. Use https://github.com/lucasg/Dependencies to check that. -
I tried, I ran in release mode and used windeployqt and had to copy additional lib files but it couldn't run and there was no notification, but if I run the program in debug mode, after the exe file is created, I can successfully run that file without having to run the windeployqt command or copy any additional lib files
-
i want to create exe file with qt6, i tried to create with windeployqt/windeployqt6 but after creating my exe file doesn't work and there is no error message, please help me find out the cause and how to fix it. thank you!
I use qt6.8.3 and cmake 3.50.5