2

I have an application that displays alot of images of different file formats like svg, png and jpeg. My application runs fine when I run it in my build environment, but when I deploy it to a target PC, only svg and png images will load and the others get a QML Image: Unsupported Image Format.

The image objects are on the form

Image {
    id: jpgimage
    source: images/jpgimage.jpg
}
Image {
    id: pngimage
    source: images/pngimage.png
}
Image {
    id: svgimage
    source: images/svgimage.svg
}

I am deploying my application with this command:

windeployqt --dir <my target folder> --qmldir <path the my project qml folder> <path to my executable>.exe --compiler-runtime

This will load most of my required libraries, but I have to manually copy over some missing .dll files as well, that are not Qt specific.

My target folder now have these files and folders:

my_app.log                    Qt5Widgets.dll*            libharfbuzz-0.dll*
Qt/                           Qt5WinExtras.dll*          libiconv-2.dll*
Qt5Core.dll*                  QtGraphicalEffects/        libicudt68.dll*
Qt5Gui.dll*                   QtMultimedia/              libicuin68.dll*
Qt5Multimedia.dll*            QtQml/                     libicuuc68.dll*
Qt5MultimediaQuick.dll*       QtQuick/                   libintl-8.dll*
Qt5Network.dll*               QtQuick.2/                 libpcre-1.dll*
Qt5Qml.dll*                   QtQuick3D/                 libpcre2-16-0.dll*
Qt5QmlModels.dll*             QtTest/                    libpng16-16.dll*
Qt5QmlWorkerScript.dll*       QtWinExtras/               libstdc++-6.dll*
Qt5Quick.dll*                 my_app.exe*                libwinpthread-1.dll*
Qt5Quick3D.dll*               audio/                     libzstd.dll*
Qt5Quick3DAssetImport.dll*    bearer/                    mediaservice/
Qt5Quick3DRender.dll*         iconengines/               platforminputcontexts/
Qt5Quick3DRuntimeRender.dll*  imageformats/              platforms/
Qt5Quick3DUtils.dll*          libbrotlicommon.dll*       playlistformats/
Qt5QuickControls2.dll*        libbrotlidec.dll*          qmltooling/
Qt5QuickShapes.dll*           libbz2-1.dll*              styles/
Qt5QuickTemplates2.dll*       libdouble-conversion.dll*  translations/
Qt5QuickTest.dll*             libfreetype-6.dll*         virtualkeyboard/
Qt5RemoteObjects.dll*         libgcc_s_seh-1.dll*        zlib1.dll*
Qt5Svg.dll*                   libglib-2.0-0.dll*
Qt5Test.dll*                  libgraphite2.dll*

And my imageformats folder contains

qgif.dll*   qico.dll*  qjpeg.dll*  qtga.dll*   qwbmp.dll*
qicns.dll*  qjp2.dll*  qsvg.dll*   qtiff.dll*  qwebp.dll*

This is running on a Windows 10 PC, also built on Windows 10 using mingw64 and the qt library installed there via msys2, and the windeployqt executable used is also from mingw64.

The target PC is freshly installed and has no environment variables set, and the application runs and the svg and png images are shown, but not the jpg images.

I have had a few tries before getting a deployed application to work, so it is highly likely I am missing something obvious in this process.

*edit: I also tried adding debug output printing the library paths:

qDebug() << "QCoreApplication::libraryPaths(): " << QCoreApplication::libraryPaths();

This printed my target folder path (the one above containing my application and all the libraries).

steinio
  • 21
  • 4
  • Try running the application with `QT_DEBUG_PLUGINS=1` to see if it's having trouble loading `qjpeg.dll`. – Mitch May 06 '21 at 09:02
  • where do you set this flag? I am building with cmake, would it then be -DQT_DEBUG_PLUGINS=1 ? *edit: oh it is an environment variable, will try and get back to you. – steinio May 06 '21 at 10:17
  • This gave me: QLibraryPrivate::loadPlugin failed on "C:/apps/my_app/imageformats/qjpeg.dll". Looks like it fails to load half of the .dll files in the imageformats folder, for instance it loads this: loaded library "C:/apps/my_app/imageformats/qtga.dll". When running this flag in my build environment, it loads all the .dll files without any issue. I have tried to run my target folder on several different windows 10 PCs now, all giving the same error. – steinio May 06 '21 at 10:24
  • Use DependencyWalker (https://dependencywalker.com) on qjpeg.dll on the target machine. It may require that a particular MSVC runtime be installed on the target machine. More info here: https://doc.qt.io/qt-5/windows-deployment.html#application-dependencies – David K. Hess May 06 '21 at 12:32
  • You can get it (e.g. vc_redist.x64.exe) from here by the way: https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0. I package that with my application and document that the user may need to run it, but you can also make it part of the installation process if you have an installer. – Mitch May 06 '21 at 13:18
  • I ran dependency walker on both computers, and the only thing missing on both are a large number of "API-MS-WIN-XXXXXXXXXXX.dll" and "EXT-MS-XXXXXX.dll" files, which I have read is a common issue in windows 10 and does not do anything. Also, I am building the application with mingw64 compiler, så no microsoft redist libraries needed. – steinio May 06 '21 at 13:54
  • I tried removing my build environment variables, and now I get the same issue on my PC. I tried just moving all libxxx.dll files from my build env into my project and removing them one by one, and finally found the missing libraries. It was libdeflate.dll* libjpeg-8.dll*. I should have probably searched for libs with jpeg in the name retrospectively, but all other missing libs caused a runtime error, except these two. – steinio May 06 '21 at 14:28

1 Answers1

0

windeployq does not move all the run-time libraries needed and I was missing two .dll files to remove all imageformats library issues:

libdeflate.dll
libjpeg-8.dll

The first was for tiff and the second for jpeg and a few other variants.

All other missing libraries after calling windeployqt raised a run-time error, except these two. Dependency Walker did not detect these two missing either.

steinio
  • 21
  • 4