0

I just Build my Project and now when i click the executable file (.exe), i gives errors that some .dll files are missing, so i referred this page https://doc.qt.io/qt-5/windows-deployment.html which says that i can use Windows Deployment Tool, which is found in QTDIR/bin/windeployqt folder directory, but when i go to the path in the image c\Qt\5.14.1 enter image description here

i see that i have all these folders and all of them have bin folders, so to solve this i i went into visual studio , Extensions->QT VS Tools-> Qt options and this thing shows up ,where i got to know the version i am using enter image description here

so, i opened command prompt and did this enter image description here

After that, in my applications .exe folder, i see some more .dll files being added, but still i get the same errors missing Qt5Widgets.dll,Qt5Core.dll,Qt5Gui.dll, i have all of those but the name ends with d, should i try renaming them ?

enter image description here

the_learnist
  • 69
  • 1
  • 8
  • I have a similar problem. Are you able to run it in debug mode? In [this question](https://stackoverflow.com/questions/62559840/how-to-solve-the-no-qt-platform-plugin-could-be-initialized-problem), I explained that somehow debug mode worked, release mode didn't. In the answer, someone gave me links to questions about similar topics too. Maybe your problem is closer to one of them, than mine; so check them out. –  Aug 16 '20 at 13:43
  • 1
    1) `set PATH=` completely replaces the existing PATH, you probably want `set PATH=;%PATH%` to add to it, instead. 2) "*VCINSTALLDIR is not set*" means the VS environment is not set, you need to run that at the VS developer prompt, instead. 3) "*GafUI.exe 64 bit, debug*" shows that QT misidentifies your .exe as being a debug build, possibly because of 1) and 2), which causes it to copy the debug DLLs over (those with the "d" suffix) instead of the release ones that the .exe requires. – dxiv Aug 17 '20 at 00:20
  • @dxiv , Thanks for info, i have not done any of that, but deleted my Release build, build my project again for a fresh start, and created a qt.conf file , like my answer below, it works perfectly fine, any drawbacks of going with this approach, ?? like the application not working on computer's which don't have Qt ?? – the_learnist Aug 17 '20 at 02:07
  • 1
    No problem with the qt.conf file per se, but you'll need to remember to update it if you ever move QT to a different directory, and also tell friends to (install QT and) do the same if they want to run your app. – dxiv Aug 17 '20 at 02:13
  • well, i understood my approach of .conf will not work if my friend does not have QT installed, what if i want to run it even though my friend doesnt have qt installed , how can i do that , by the initiall approach i was trying ?? – the_learnist Aug 17 '20 at 02:16
  • 1
    @the_learnist Yes, you would need to include the QT runtimes that your app depends on. For a real life example, take a look at the .zip distribution of [xnview mp](https://www.xnview.com/en/xnviewmp/) to see how they do it (but *your* list of DLLs would not necessarily be the same as theirs). – dxiv Aug 17 '20 at 02:52
  • @dxiv, Thanks for all your suggestions, I am not gonna go with the .conf approach since i want my application to work on other computers without QT but, yeah , 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 then `windeployqt 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 . – the_learnist Aug 17 '20 at 03:38
  • 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. – the_learnist Aug 17 '20 at 03:43
  • 1
    @the_learnist `vcruntime140d.dll` and the other `"d"` ones are *debug* dlls. They are not redistributable, and you should not send out debug builds, anyway. As to why `windeployqt` mistakes your .exe for a debug build, that I don't know but it seems you can override that with the [`--release`](https://doc.qt.io/qt-5/windows-deployment.html) command line switch, and then it should copy the right set of non-debug dlls. – dxiv Aug 17 '20 at 04:33
  • oh , that's nice ,how do i use --release option , is it like `windeployqt --release C:\projects\GAF_Updated\GAF\x64\Release\GafUI.exe`. ? – the_learnist Aug 17 '20 at 05:21
  • 1
    @the_learnist That would be my reading of the linked page, yes. – dxiv Aug 17 '20 at 18:31
  • 1
    Thanks for your help and suggestions. My issue is solved now. – the_learnist Aug 17 '20 at 22:59

1 Answers1

0

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.

the_learnist
  • 69
  • 1
  • 8