PDA

View Full Version : Functionality of the QCoreApplication::addLibraryPath() method



Momergil
10th December 2013, 00:07
Hello!

I'ld like to know more about exactly what the named method is for or, more specifically, if it works for what I want.

Given its name and its description in the help files, I understood that this function is used to append a different, non-default library path, that is, a path where Qt will try to locate libraries related to my application.

Well, that seems exactly what I need: imaging me developing a series of Qt apps, all of each dinamically compiled, I noticed that a series of my applications installed on my computer would lead to a couple of Qt5Core.dll, Qt5Gui.dll, etc.. copied in one's computers, a quite waste of memory. Trying to surround this problem, I decided that all of my apps would be installed in the same folder (lets say, C:/Program Files/Momergil). But the result was that now I have a folder ("Momergil") with all, non repeated Qt dlls and lots of different executable files, each for one application - which is quite a mess. Trying to surround this new problem, I decided that I'ld like to put all the executables in a folder with the software's name, while this folder would be located in the original, now only for dlls directory.

So for example, If I had a software called "Test.exe", I'ld set Inno Setup to put Qt5Core.dll, etc. in a folder called "C:/Program Files/Momergil" while "Test.exe" would be in "C:/Program Files/Momergil/Test".

The problem is that now the .exe file wouldn't locate Qt's dlls. And here I thought addLibraryPath() would solve my problem (in this case, by adding "C:/Program Files/Momergil" with this method - or, more specifically, "./" or "../"), but it didn't.

Searching about it on the web I found comments about this method only being valid for plugins, not for Qt's DLLS (in this case, shouldn't it be called "addPluginPath" instead?). Well, is this true? And if it is so, how could I tell my .exe that Qt's Dlls are in the folder they are? (not forgetting that this is relative to where the user decided to install all my apps).


I'm glad for any help,

Momergil

anda_skoa
10th December 2013, 09:43
addLibraryPath() does indeed add library search base paths, but for runtime loaded libraries, e.g. plugins.

It is code executed by the program once it has started, just like any other code that you as the application developer write. That is too late for start-up requirements, which need to be satisfiable by the systems dynamic linker.

So this is actually not a Qt questions but rather a question of the target platform. You'll have to look for the system's library handling capabilties, e.g. if it allows to register libraries so that installers can find them, etc. Something to be better asked in a forum for the respective operating system.

Your idea of having a "vendor" directory does seem quite good though. You have full control over it and it really doesn't matter if it contains a lot of files, nothing other then your installers will interact with it.

Cheers,
_