[Interest] Is it ok to use QLibrary to load and unload different shared libraries in sequence?

Roland Winklmeier roland.m.winklmeier at gmail.com
Wed Oct 24 11:58:25 CEST 2018


Hi there,

I have a quick question about QLibrary. I'm connecting to a 3rd party
application software by using the 3rd party application's SDK. That SDK is
a single proprietary Windows dll and there is a different dll for each
version of the application. I would like to support the connection to
several versions of the application at runtime, hence I have all the dll
files in my bin folder:

bin/ApplicationConnect-4.0.dll
bin/ApplicationConnect-4.1.dll
bin/ApplicationConnect-4.2.dll
...

At runtime, depending on the user configuration, any of those versions are
loaded and symbols resolved using e.g. QLibrary
myDll("ApplicationConnect-4.0"). That all works perfectly fine. Now I would
like to add the feature to switch versions at runtime and here is my
question:

Is it fine to reuse the same QLibrary instance in the following sequence:
QLibrary myDll("ApplicationConnect-4.0");
myDll.load()
[... resolve and do stuff ...]
[... User configured different version...]
myDll.unload
myDll.setFileName("ApplicationConnect-4.1")
myDll.load()
[ ... resolve symbols and continue using it...]

or shall I destroy the previous QLibrary instance and create a new one?

I got some strange behavior while debugging the above lines in QtCreator
(error message saying that "Command aborted" after the first unload and gdb
aborts). So I'm not sure if I do something totally wrong.

Thanks,
Roland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20181024/a9e1ca8c/attachment.html>


More information about the Interest mailing list