How to deploy Qt program that relies on a 3rd party library?
-
Hi there. I've spent the last 4 hours (!!!) attempting to deploy a Qt (5.6) application I'm developing onto another machine. It works perfectly on my machine (Windows 7 x64), but immediately and silently closes when launched on both of the other test machines I've tried (Win7 x64 and Win10 x64).
I followed the instructions here:
https://wiki.qt.io/Deploy_an_Application_on_Windows
and after that failed I tried through windeployqt.Both methods led to an .exe that silently closed on launch. No error messages complaining of missing DLLs or any other signs that could help diagnose the problem.
On the target machines, I installed the Visual C++ 2013 runtime and libusbK (the external library). The Qt DLLs (and plugins) were included in the .exe's folder.I finally created a dummy app that did not rely on any external libraries and attempted deploying that. Everything worked perfectly.
So, the question is, is there a special method I need to use to include external libraries when deploying on a remote system? Or is it likely an issue specific to libusbK and I'd have better luck asking the people there?
Thanks,
~Chris -
Hi, welcome to the forum
The usual way you deploy 3rd party libraries is by placing their dlls in your app folder, just like you do with Qt. If that's not the case then the other options are to place the dlls in a system folder like
Windows
, but that's a very uncool thing to do and IMHO only system components should do that. Yet another option is to put the path to the dlls in the PATH variable, but that's something I personally hate when apps do and I highly discourage it.
The most civil way is to just put all your stuff in one place, next to the executable.You said you "installed" libusbK. What does that mean? Is there some kind of installer or did you just copy some dlls over?
Some libraries (like Qt) don't have a special runtime installer and they expect you to deploy them however you like. Some other just copy their files to some folder, set an environment variable or a registry key to point there and expect your app to look for them there and load dynamically. Yet others have an installer that sets up PATH or installs in Windows folder (like the C++ runtime).It's a question of how libusbK expects you to deploy it.
Also, you might want to try to run Dependency Walker in the profile mode on the target machines to confirm that it's the libusbK that is causing a problem or something else is missing. -
Thanks Chris. I installed LibusbK using the official installer. I believe it places the DLLs on the user's machine and then adds them to PATH. But that wasn't the issue...
I actually found the cause today after spending another few hours trying to chase down the "missing" DLLs.
It had nothing to do with Qt or any 3rd party library, and everything to do with my own poor programming.
Weeks back, I'd written some code that used an absolute path to open a text file, with the idea being that I'd change it to a relative path once all of the bugs related to parsing the file were ironed out. Of course, I completely forgot that this code existed and just continued on with development.
And when moving to the new machine that didn't have the exact file in the exact location, all hell broke loose.The joys of being a rookie engineer!
-
Ah, yes, the "temporary solutions" :)
I'm glad you figured it out. Happy coding.