Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to deploy dlls?



  • Hi, I'm trying to deploy a dll that uses the QSerialPortInfo.

    QT is version 5.12.6 and project using MSVC2017 64b

    windeployqt.exe writed this:
    Direct dependencies: Qt5Core Qt5SerialPort
    All dependencies : Qt5Core Qt5SerialPort
    To be deployed : Qt5Core Qt5SerialPort
    Warning: Cannot find Visual Studio installation directory, VCINSTALLDIR is not set.
    Qt5Core.dll is up to date.
    Qt5SerialPort.dll is up to date.
    Patching Qt5Core.dll...
    Creating qt_ar.qm...
    Creating qt_bg.qm...
    Creating qt_ca.qm...
    Creating qt_cs.qm...
    Creating qt_da.qm...
    Creating qt_de.qm...
    Creating qt_en.qm...
    Creating qt_es.qm...
    Creating qt_fi.qm...
    Creating qt_fr.qm...
    Creating qt_gd.qm...
    Creating qt_he.qm...
    Creating qt_hu.qm...
    Creating qt_it.qm...
    Creating qt_ja.qm...
    Creating qt_ko.qm...
    Creating qt_lv.qm...
    Creating qt_pl.qm...
    Creating qt_ru.qm...
    Creating qt_sk.qm...
    Creating qt_uk.qm...
    Creating qt_zh_TW.qm...

    I copied my dll and other files that added by windeployqt to right program directory, but doesnt work, program cannot load this. If i create this dll without QSerialPortInfo, program dll correctly loading.


  • Lifetime Qt Champion

    @Pavel-Hudecek You can use https://www.dependencywalker.com/ to see which libs are missing.



  • Thank you, I try it, but many errors "System cannot find file" occured. These errors occurs with both "loadable" and "no-loadable" dlls. Help in this program doesnt work.
    alt text



  • I tried to deploy a exe with this component, it works. Next i copied all files around deployed exe to directory of the dll, but dll not work, the program cannot load this. I think the problem is not with the wrong deploy of the dll, but with the method of on demand loading the dll into the program.

    This is crazy. It's relative big software, hunderds of cpp files, full build time is more than 10 minutes. First author was genius, he wrote everything self, but without any comment and documentation... and he left:-) Now, more people are trying to continue in the project.

    I find that the program use winapi LoadLibraryW to on demand loading of a dlls. And if dll is using a QT component, LoadLibraryW cannot load it.

    Any hint what i can change in my dll, or i must change main program?


  • Moderators

    @Pavel-Hudecek , you can ignore the 'yellow entries' with API-MS_WIN .. in dependency walker.

    There might be multiple reasons why a .dll isn't loaded in the original program. Try to also load the actual executable (that does LoadLibrary calls) into dependency walker. Then run it with 'Start profiling...'. There are multiple options available, but the defaults should be fine.

    Does depends.exe give you any output when it tries to load your .dll?



  • Hi, there's one difference between a Qt .EXE file and a Qt DLL: when Qt loads the plugins it needs, for an .EXE usually all that's needed is to copy the Qt .dlls and plugins to the same directory as the .EXE file, because Qt looks for the dlls in the current working directory, i.e. where the .exe file is, this works fine.

    However, if your Qt .DLL is not in the same directory as the .EXE file that loads it, the current working directory method of location the needed Qt plugins will not work, this might be why QSerialPortInfo fails to load.

    One way to fix this problem is in your Qt Dll main.cpp, just before constructing the QApplication, is to call addLibraryPath and specify the directory where your .DLL is.


Log in to reply