When I release my Qt
project, I want to redistribute the QtCore4.dll
and QtGui4.dll
files with my project, but not in the same directory as my .exe
(in some other relative path).
How can I make my .exe
find them automatically?
I also don't want to set the %PATH%
or any other environment variable in my customer's environment.
Probably the safest way is to launch your application using a script that does change the PATH
(but only for that session) before launching your application. Here is a script I use to launch a custom version of Qt Creator
:
set PATH=%PATH%;C:\Qt\qt474_custom_msvc2008_x64\lib;C:\Qt\jom
start C:\Qt\qtcreator231__custom_msvc2008_x64\bin\qtcreator.exe
I think there are alternatives, like SetDllDirectory, but (just like rpath
on *nix), they introduce other problems. Either side-by-side dlls or a change in the PATH seems to be the most stable solution.
Also, did you mean that you want to deploy the debug versions (QtCore*d*4.dll, etc.) of those dlls? That would be pretty unusual--make sure you use the release versions. (Unless, of course, you have a valid reason for using the debug versions.)
First, you should reconsider not changing the PATH
in your customer's environment: many projects/applications do that, so you should consider that as a real option.
Second, the best way of doing this seems to be by editing a qt.conf
file placed in the same folder as your executable. See this link for more information about editing an qt.conf file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With