How to make my Qt application load dlls in a different folder?
-
How to set my qt project to search for the dependent DLLs in a different folder than the exe folder?
I can't compile it as static because I'm using the
QWebEngine
module which didn't support being built statically.These are some things I already tried:
Creating a qt.conf file in the same folder of the exe and specifying a path.
[Paths] Prefix = D:/Project/New folder
SetDllDirectory, addLibraryPath
//SetDllDirectory(L"D:/Project/New folder"); //QList<QString> list = {"D:/Project/New folder"}; //QCoreApplication::setLibraryPaths(list); QCoreApplication::addLibraryPath("D:/Project/New folder"); QApplication a(argc, argv);
I was not sure when to call these 3 options, I tried calling then before the
QApplication
line.I have been able to deploy it using
windeployqt
, the project is being built usingQt 6.4
andVisual Studio 2019
. -
How to set my qt project to search for the dependent DLLs in a different folder than the exe folder?
I can't compile it as static because I'm using the
QWebEngine
module which didn't support being built statically.These are some things I already tried:
Creating a qt.conf file in the same folder of the exe and specifying a path.
[Paths] Prefix = D:/Project/New folder
SetDllDirectory, addLibraryPath
//SetDllDirectory(L"D:/Project/New folder"); //QList<QString> list = {"D:/Project/New folder"}; //QCoreApplication::setLibraryPaths(list); QCoreApplication::addLibraryPath("D:/Project/New folder"); QApplication a(argc, argv);
I was not sure when to call these 3 options, I tried calling then before the
QApplication
line.I have been able to deploy it using
windeployqt
, the project is being built usingQt 6.4
andVisual Studio 2019
. -
@Roberrt On Windows you need to add the folder containing your libraries to environment variable PATH before starting your app.
-
I have put all dependencies in the folder
D:\New folder
and added it under the user Environment Variables, is it correctly?I tested it, but it still complains about missing DLLs.
-
@Roberrt I was talking about PATH variable. I can't see it in your screen shot. And keep in mind: if you do it this way you will need to log off and on again.
@jsulm said in How to make my Qt application load dlls in a different folder?:
PATH variable
To clarify, are you referring to
System Variables
>Path
variables?I've added the folder and rebooted, but now I'm getting this error:
This application failed to start because no Qt platform plugin could be initialized.
This is my dependencies folder:
-
@jsulm said in How to make my Qt application load dlls in a different folder?:
PATH variable
To clarify, are you referring to
System Variables
>Path
variables?I've added the folder and rebooted, but now I'm getting this error:
This application failed to start because no Qt platform plugin could be initialized.
This is my dependencies folder:
@Roberrt said in How to make my Qt application load dlls in a different folder?:
are you referring to System Variables > Path variables?
I'm referring to PATH environment variable.
You can set it in System Variables > Path variables. But as I already pointed out above: you need to log off and log in again after changing PATH. If it then still does not work then open a terminal and enter command "set" - check the value of the PATH variable there.
You should also consider that using paths with spaces can easily cause problems. -
@Roberrt said in How to make my Qt application load dlls in a different folder?:
are you referring to System Variables > Path variables?
I'm referring to PATH environment variable.
You can set it in System Variables > Path variables. But as I already pointed out above: you need to log off and log in again after changing PATH. If it then still does not work then open a terminal and enter command "set" - check the value of the PATH variable there.
You should also consider that using paths with spaces can easily cause problems.@jsulm said in How to make my Qt application load dlls in a different folder?:
You should also consider that using paths with spaces can easily cause problems.
I modified it to a path without spaces, and rebooted, continue getting the same error message.
If i execute the exe inside of the DLL folder it works correctly.
I think the problem is these folders dont?
I used
windeployqt
to copy the dependencies, is it possible to 'copy' everything without creating any folder? -
@jsulm said in How to make my Qt application load dlls in a different folder?:
You should also consider that using paths with spaces can easily cause problems.
I modified it to a path without spaces, and rebooted, continue getting the same error message.
If i execute the exe inside of the DLL folder it works correctly.
I think the problem is these folders dont?
I used
windeployqt
to copy the dependencies, is it possible to 'copy' everything without creating any folder?@Roberrt What about my suggestion from above: "If it then still does not work then open a terminal and enter command "set" - check the value of the PATH variable there.". If the PATH is set correctly try to start your app from a terminal - does that work?
-
@jsulm yes, when i enter "set" in the terminal i can see the path.
I tried launching the app using the terminal it gave the same error.
-
@Roberrt If c:\Users\Public\Qt is the folder with your libs it should work.
You also tried to use qt.conf: did you specify the folder with the libs using "Libraries = PAT_TO_LIBS_FOLDER"? Prefix is the app folder.@jsulm
I got it working for a new project containing just a push button, I also needed to create a variable with the nameQT_PLUGIN_PATH
under the System variables environment, and set the folder which contains these plugins folders (platforms, etc), in my caseC:\Users\Public\Qt
.But for my app using
qwebengine
its not working, when i run the exe i don't see any error message neither my gui, then it closes :(