0

I create a Qt app. It uses Qt dlls and also libusb dll and openssl dlls. And I use Qt Installer Framework and with windeployqt I bundle all these dlls in the same folder as my app. So when it's extracted on the user's system it all works well as the dlls are right next to the app exe so the dlls are discovered correctly.

Now I want to add my app.exe to PATH environment variable. I can do it with the Qt Installer Framework. But the problem is that the dlls that come with my app will be now exposed to PATH too. And it does not look good. How do people normally solve the problem?

Maybe, it's bad to add/remove my app to/from PATH on installation/deinstallation? However, I've checked out that e.g. CMake's and Python's installers do modify the PATH, though it looks like they do it using Wix toolset or something like this, while I use Qt Installer Framework: JavaScript where I specify Powershell commands to get executed.

JenyaKh
  • 2,040
  • 17
  • 25
  • you only need to know where the dlls are located relative to the executable, they need not be in the same folder – 463035818_is_not_an_ai Dec 16 '22 at 09:49
  • But I do not load them dynamically. They are loaded automatically on startup. So they should be either on PATH or at the same folder as my app.exe. – JenyaKh Dec 16 '22 at 09:51
  • ***And it does not look good. How do people normally solve the problem?*** I don't worry about it at all. Although most of my Qt based applications which I have written since 2008 are used in house for medical imaging research purposes. – drescherjm Dec 16 '22 at 12:38
  • ***Maybe, it's bad to add/remove my app to/from PATH on installation/deinstallation?*** This depends on your needs. Do your users need to execute your program from powershell or cmd.exe? If not you probably don't need to put your binary folder in the PATH. – drescherjm Dec 16 '22 at 12:40
  • Why don't you care? Is not it that your dlls can interfere with someone's else app? Are your applications used in cmd/powerfully, BTW? Well, I try to create an app that supports both gui and cli mode, so for the cli -- I try to add it to PATH. This was my first move. But now I'm in doubt if it's okay to play with a user's PATH at all unless it's really crucial. – JenyaKh Dec 16 '22 at 13:16
  • ***Is not it that your dlls can interfere with someone's else app?*** Outside of the third party dlls like Qt, vtk, boost itk ... which have versions in their naming my own dlls will be named uniquely so no chance of conflict. – drescherjm Dec 16 '22 at 13:28
  • You know, on second thought, I've got a question. You say that there is a version in qt's dll naming. But the name is Qt5Core.dll. So there maybe any version of qt in there: e.g. 5.12 or 5.15. Isn't it a problem if an app using qt 5.15 would try to link against my Qt5Core.dll which is 5.12 and was put in PATH by me? – JenyaKh Dec 17 '22 at 07:58
  • I am sorry for Qt its just the major version and not a full version. – drescherjm Dec 17 '22 at 23:24
  • You could use a manifest file and put the dlls in a different folder: [https://stackoverflow.com/questions/37792366/how-to-create-manifest-file-for-qt-standalone-application](https://stackoverflow.com/questions/37792366/how-to-create-manifest-file-for-qt-standalone-application) and [https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications](https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#search-order-for-desktop-applications) – drescherjm Dec 17 '22 at 23:28
  • Related to my previous comment: [https://stackoverflow.com/questions/3832290/altering-dll-search-path-for-static-linked-dll](https://stackoverflow.com/questions/3832290/altering-dll-search-path-for-static-linked-dll) – drescherjm Dec 17 '22 at 23:36
  • Thank you for your help! I will try to further investigate on the manifest file approach. For now by just reading through these and some other related links I have not grabbed how to do it yet. Maybe, practice will help. – JenyaKh Dec 18 '22 at 12:52
  • I admit I have not used that approach myself but I was aware of it. – drescherjm Dec 18 '22 at 14:40

0 Answers0