Windows deployment and missing DLL dependencies



  • Hello
    I'm trying to deploy my application on windows; after running qtenv2.bat and vcvarsall.bat, I launch windeployqt.exe.
    The tool successfully finds and deploy all the Qt5*.dll dependencies (even a dll I manually built, Qt5Pdf.dll), but fails to find a dependency to another dll I had to build to compile the program (in the specific, qca-qt5.dll). The logs show nothing about that dll, but the Depends tool finds its dependency.
    Moreover, trying to launch the executable fails due to the missing qca-qt5.dll.

    Why the program can't find this dependency?

    Thanks



  • Hi, there's one difference between how windeployqt.exe and the Depends tool: windeployqt.exe looks only for .dlls that your .exe file depends on, but the Depends tool also looks for .dlls that your other .dlls depend on.
    (For example, I have a Qt .dll that does the database stuff for me, and it needs Qt5Sql.dll, but since my main .exe file only needs my Qt .dll and not directly needs Qt5Sql.dll, windeployqt.exe never copies Qt5Sql.dll for me, I have to copy it manually.)

    So maybe you have a similar situation, i.e. your .exe file does not directly depend on qca-qt5.dll, but rather one of your other .dll does?



  • Hmm... if this would be the case, then it would be an indirect dependency from one of Qt5* libs, since the only non-default lib I'm using is Qt5Pdf, that is not requiring qca-qt5.

    Under Depends, though, the qca-qt5 dependency appears in the "root", and not under another dll tree



  • Yes, if it's listed under the root, then it should be the .exe file that needs the qca-qt5 dll. And then windeployqt should be able to pick it up, but it does not, it seems it only cares about the standard Qt dlls when checking the .exe file. I.e. I think you have to copy the qca-qt5 dll into the release directory manually.

    Edit: Verified this by looking at windeployqt's source code (it's just a single file: qt-everywhere-src-5.12.3/qttools/src/windeployqt/main.cpp) and indeed windeployqt is ignorant about non-Qt dlls. It has a array of kosher .dll file names (qtModuleEntriesp[) and if your .dll is not in there, you're out of luck :-(



  • Strange that the same isn't happening with Qt5Pdf then.

    My main issue was if it was normal that something had to be copied manually to package an application



  • Aha, it copies Qt5Pdf.dll? Perhaps it's because that .dll passes as a "kosher" Qt dll, because the name starts with Qt5... (windeployqt's source code has such a check).



  • This is sad. Thx for the info



  • @mewster Maybe not sad, but a tad simplistic.

    I've looked more in windeployqt's source code and it turns out it does recursion on the .dll lookups (so I was wrong above, it behaves like the Depends tool), but, since it censors what .dlls to include/lookup, the end result is a bit lacking. But it has to censor, because otherwise it would try to copy kernel32.dll, gdi32.dll, user32.dll etc. as well.

    Anyway, I was thinking, this is open source after all, maybe it's possible to add another "kosher" prefix or name to the whitelist of dll names that windeployqt uses. Currently it has only one (hardwired) entry (the 5 is derived from Qt's current major version):
    "qt5*"

    In my Qt deployment I have up to 4 custom Qt dlls to distribute along with my .exe files (which I copy manually) but they have a common prefix in their names. So one idea is: if it's possible to add a --prefix switch to windeployqt's command line, to extend the whitelist.

    For example, in your case, it could be:
    windeployqt --prefix "qca-qt5"

    That would give qca-qt5.dll the same kosher status as your Qt5Pdf.dll enjoys today.

    One question: the list of dependent dlls for an .exe file only include the filenames, the source path windeployqt uses for the copying seems to be Qt's bin directory only. So, in order for your Qt5Pdf.dl to be successfully copied by windeployqt, did you first copy Qt5Pdf.dl into Qt's bin directory?



  • @hskoglund said in Windows deployment and missing DLL dependencies:

    One question: the list of dependent dlls for an .exe file only include the filenames, the source path windeployqt uses for the copying seems to be Qt's bin directory only. So, in order for your Qt5Pdf.dl to be successfully copied by windeployqt, did you first copy Qt5Pdf.dl into Qt's bin directory?

    Yep, both Qt5Pdf.dll and qca-qt5.dll are inside C:\Qt\5.12.3\msvc2017_64\bin (same folder as windeploy). They were automatically copied with their post-build installation


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.