2

I was informed about the "windeployqt" utility, which should be able collect all Qt/MinGW DLLs that are required to run my Windows Qt application properly. So I gave it a try.

Unfortunately I have noticed that it collects more files then neccessary. I compared the files collected by the windeployqt utility against the ones that are reported by the "Dependency Walker". The files that are really required have been collected properly, but also following files were collected for some reason:

Qt5Svg.dll
iconengines\qsvgicon.dll
imageformats\qdds.dll
imageformats\qgif.dll
imageformats\qicns.dll
imageformats\qico.dll
imageformats\qjp2.dll
imageformats\qjpeg.dll
imageformats\qmng.dll
imageformats\qsvg.dll
imageformats\qtga.dll
imageformats\qtiff.dll
imageformats\qwbmp.dll
imageformats\qwebp.dll

The application just deals with QBus and uses QWidgets to display a simple Window. Therefore I see no reason why these DLLs have been collected.

Willy K.
  • 397
  • 2
  • 14
  • How did you invoke 'windeployqt' ? – Mohammad Kanan Oct 13 '17 at 12:41
  • On clean machine where you dont have installed any development tools open the application and go in the folder where you have all dlls. Select all and go shift+delete, dlls that are not used by the app will be deleted. – Angel.Risteski Oct 13 '17 at 13:49
  • @Mohammed Kanan: I use CMake in a Qt/MinGW build environment, where winqtdeploy is invoked by _add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND windeployqt --force --debug --no-translations --dir "${CMAKE_BINARY_DIR}/dist/bin" "${PROJECT_NAME}.exe") – Willy K. Oct 13 '17 at 14:09
  • @Angel Risteski: Thanks for the nice tip. But the goal is that our automated build system will output a proper set of binaries. – Willy K. Oct 13 '17 at 14:09

2 Answers2

2

windeployqt utility will parse your "EXE" file and determine what packages were used, then it copies needed DLLs accordingly. Make sure to invoke the utility in a configured/set environment.

I use the utility in this way:

  • Perform release clean build of the project and record build path and "exe" generated. For insrance

    c:\myApp\release\ and myApp.exe

  • Create deployment folder // other than the release build folder//. for instance

c:\myApp\deploy

then invoke the utility from Qt command line utility, as follows:

- Go to all progrmas --> Qt --> Qt command line utility 
- cd c:\myApp\deploy
- windeployqt --dir . c:\myApp\release\myApp.exe
Community
  • 1
  • 1
Mohammad Kanan
  • 4,452
  • 10
  • 23
  • 47
2

The fact that a DLL is no listed by Dependency Walker does not mean it is not required.

Dependency Walker will only list DLL required for you exe to be loaded and started by Windows. But other DLLs may be loaded later, while your program is running. This happens in particular when Qt loads plugins like the image format plugins

Because it cannot know beforehand what plugin will be needed, windeployqt deploys all Qt plugins (all which are relevant in regard to the required DLLs).

You can alter the way windeployqt behaves by using command line modifiers like --no-plugins (see windeployqt -help).

You can take a look at Qt for Windows - Deployment in the Qt documentation, in particular the part about Qt Plugins.

Benjamin T
  • 8,120
  • 20
  • 37
  • It seems that the additional DLLs are "involved" because the program is using the QWidget class (GUI tool). We use ist just for displaying some text messages - it seems that this explains why we didn't had any problems even if QSvg.dll etc. were missing. Thanks. – Willy K. Oct 16 '17 at 09:41