How to set the dll path of the main program
-
My program depends on some third party dlls(not the qt plugins).
So how to make the relative path of the main program to put the dlls.
I only know the method of set PATH on windows.Are there any other solutions to solve this problem?
here's the structure of the program./main.exe ./bin/dllfiles1/third_party1.dll ./bin/dllfiles2/third_party2.dll ./other_source_files
-
simply put the dll files in the same folder of your exe file
-
My program depends on some third party dlls(not the qt plugins).
So how to make the relative path of the main program to put the dlls.
I only know the method of set PATH on windows.Are there any other solutions to solve this problem?
here's the structure of the program./main.exe ./bin/dllfiles1/third_party1.dll ./bin/dllfiles2/third_party2.dll ./other_source_files
@nicker-player You can use https://doc.qt.io/qt-6/qt-conf.html
-
simply put the dll files in the same folder of your exe file
@Ronel_qtmaster
I need to put the sub path of the exe file root.In fact,if i do that, the exe wont work cause couldnt find the dll files.@jsulm
I think the qt.conf couldnt solve my problem.because I need to put the dlls in different sub folders of the exe file.And the qt.conf seemed not working on that. -
The search order for load time DLLs is documented and doesn't allow for additional search paths. You can alter the PATH variable or the registry key for known locations, but both of these are highly discouraged. You should not modify user's system just for your app. The standard and most common way to do it is deploying your app with all the dependent DLLs in the same directory as the executable. I would suggest to setup your build system to create a structure like that.
Only runtime DLLs, like plugins or libraries loaded dynamically via QLibrary or directly with WinAPI LoadLibrary can have their search paths altered. For Qt plugins you do that with qt.conf file and for other libraries you can use SetDllDirectory.
-
The search order for load time DLLs is documented and doesn't allow for additional search paths. You can alter the PATH variable or the registry key for known locations, but both of these are highly discouraged. You should not modify user's system just for your app. The standard and most common way to do it is deploying your app with all the dependent DLLs in the same directory as the executable. I would suggest to setup your build system to create a structure like that.
Only runtime DLLs, like plugins or libraries loaded dynamically via QLibrary or directly with WinAPI LoadLibrary can have their search paths altered. For Qt plugins you do that with qt.conf file and for other libraries you can use SetDllDirectory.