Visual Studio 2019/Qt C++ Executable file not working ?
-
i was working on a Qt C++ based project and now i want to run the UI Application from an executable file like 'project_name.exe', so in the Visual Studio menu, i clicked Build->Build project_name, i notice that a project_name.exe Application file is generated in
Project_name > x64 > Release Folder,
but when i click it, i am not able to open it ,it gives me a 3 System Errors boxes saying
"The code execution cannot proceed because Qt5Widgets.dll" was not found. Reinstalling the program may fix this problem."
"The code execution cannot proceed because Qt5Core.dll" was not found. Reinstalling the program may fix this problem."
"The code execution cannot proceed because Qt5Gui.dll" was not found. Reinstalling the program may fix this problem."Any way i can solve this ?
-
@learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:
so i noticed that all .dll files were of debug, all of them ended with ...d.dll
You may want to check windeployqt documentation, especially regarding --release switch
-
Hi
You need a deployment folder to run the .exe alone
a deployment folder is a folder with the needed Qt DLLSthere is a tool you can use
https://doc.qt.io/qt-5/windows-deployment.html
it will copy the needed DLLS for you.Also explained here in good details
http://www.tripleboot.org/?p=138 -
@mrjj I am now in a state that when i click ```
project_name.exenothing happens, Here are the steps i took , i opened Developer Command Prompt for VS 2019, typed this ``` C:\Qt\5.14.1\msvc2017_64\bin>set PATH C:\Qt\5.14.1\msvc2017_64\bin
and then this
C:\Qt\5.14.1\msvc2017_64\bin>windeployqt.exe C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe
Then the errors about QtWidgets.dll, QtGui.dll missing were gone, but i was facing some other errors like libGLESv2.dll is missing, so i copied it from visual studio folder and pasted it, further i got some other errors like MSVCP140_APP.dll and also VCRUNTIME140_APP.dll is missing , so i downloaded it from the internet and pasted that dll file in my project_name.exe folder,
now when i click it , i get no errors , but when i click projectname.exe file, nothing happens,
Why is deploying in QT so tough ?
-
@learnist
Hi- Why is deploying in QT so tough ?
its only tough the first few times :)
windeployqt.exe has option called --compiler-runtime
that tells it to also copy MSVCP140_APP.dll and VCRUNTIME140_APP.Just to be sure. you go into the folder and click the .exe, correct ?
To test on same machine where Qt is installed, i often rename the c:\Qt folder
so it cant possibly find anything there.
(i check the .exe and then rename back) - Why is deploying in QT so tough ?
-
@learnist
Hi
its just a build folder so you can just delete it and rebuild to get your exe back.
Or simply press ctrl+a and
then hold ctrl and click the exe to deselect it,
then press delete button to delete anything else.Then open command prompt again and
do
C:\Qt\5.14.1\msvc2017_64\bin>windeployqt.exe --compiler-runtime
C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exedo you use openGL since it wants libGLESv2 ?
Do you use QML also ? -
@mrjj Hello mrjj, i deleted the release and build it again, so i got a fresh start here, Nope, i did not use OpenGL and QML,
i used Visual Studio 2019 when i was workin on this project. so instead of command prompt should i use "Developer command prompt for VS 2019" ??
-
@learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:
i used Visual Studio 2019 when i was workin on this project. so instead of command prompt should i use "Developer command prompt for VS 2019" ??
I
t this case it should not be important but should not hurt either.
I was wrong . its best to do.
if you have multiple Qt installed then
its important from which folder you start the actual windeployqt.exe - from -
@mrjj I have solved this by placing qt.conf file in my application's .exe folder
[Paths]
Prefix=C:\Qt\5.14.1\msvc2017_64
Defining Prefix in your qt.conf file allows it to find the qwindows.dll platform plugin when your app starts.if i have a .conf file , i know that application will work perfectly fine on my computer , but not on my friend's computer in which there is no QT installed,
so what i have done is i opened 'Developer command Prompt for Visual Studio 2019' and did this
C:\Windows\System32>set PATH=C:/Qt/5.14.1/msvc2017_64/bin;%PATH%
and thenwindeployqt C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe
but still my application.exe was not working, so i noticed that all .dll files were of debug, all of them ended with ...d.dll , for example QWidgetsd.dll, so i deleted them and copied the correct .dll files
i copied correct .dll files(which dont end with 'd') from C:\Qt\5.14.1\msvc2017_64 folder , now my application.exe works,but, there are still some dlls , which i can find in C:\Qt\5.14.1\msvc2017_64 folder , but these are like msvcp140_1d.dll, vcruntime140d.dll , i dunno where can i find them , coz these are not QT specific. these are visual studio related.
-
@learnist said in Visual Studio 2019/Qt C++ Executable file not working ?:
so i noticed that all .dll files were of debug, all of them ended with ...d.dll
You may want to check windeployqt documentation, especially regarding --release switch
-
@Pablo-J-Rogina Thanks , This worked just perfect.