[SOLVED] Change default location of QtCore.dll and QtGui.dll
-
Dear Qt developers,
This is probably going to be a very simple question but yet I cannot find an answer using Google nor the search option here on the forums.
By default, if I want to run a Qt app I need to have both QtCore.dll and QtGui.dll in the same folder as my .exe file. Is there any way to move those files into let's say a /dll folder and tell my app to look for them inside? I'm guessing it's somewhat linker connected but as I stated - can't find an answer.
Why do I want to do that? Because in my applications folder I want to have only my executable file and no other files present. It will look nice :-).
Looking forward to an answer.
Best regards,
Daniel.
-
Those files need to be in the path. In the same directory as the .exe works very well for that, as it is the first place windows looks so you never end up in version conflicts, but you can also define other places. However, you can AFAIK not do that from within your own program (as you can for plugins), as at that point your program already needs to have found the libraries.
One option may be a startup script however: a script that basically sets the path to search for libraries to whatever you need it to be, and then starts your application executable itself.
-
Thank you for your answer Andre. Now I'm thinking about a different way of achieving that (I want to be as far as possible to batch files, I want the application to be as OS independent as possible). Please tell me if any of those ways are elegant ;-):
-
Put my whole application into a library and move it along with Qt's libraries to a different folder. Then write a small program which will load up my library and transfer control to it.
-
Have 2 separate executables. First one is going to be the main application itself put into the /dll folder and the second one will only start up the previous one and close itself down.
-
-
If you really want such a solution, I would prefer solution 2. I have sometimes seen such things.
But solution 1 does not solve the problem, as you have to load the dll then by LoadLibrary which will implicitly try to load the Qt libs. But they are not inside the search path then...Regarding the platform independency:
none of the solutions is works on all platforms.
Windows loads dll as follows:
Location of the executable
current dir
win32 directory
search the PATH variable
Linux uses another aproach
search directories from env variable: LD_LIBRARY_PATH
The list of libraries cached in /etc/ld.so.cache.
/lib, followed by /usr/lib.
-
I think the second one is definitely better. If you go for the first one, then you'll need to at least write another C/C++ application in order to load in the libraries. Using the second option, you need no more than a very simple batch script (in Windows) to launch another application.
The problem here is that if you need to write another C/C++ application, you might one day need to worry about the libraries needed for that application.