Load dynamic library failed
-
My project (Windows Platform) need to load a dynamic library which was developed with Qt but not the same version as my own project. Because the dynamic library files of different Qt versions shares the same file name, I cannot put them in one fold (the fold of .exe file exactly). I put my Own Qt version library files there, so the dynamic library developed with other Qt version cannot be used. What can I do to solve this problem?
-
My project (Windows Platform) need to load a dynamic library which was developed with Qt but not the same version as my own project. Because the dynamic library files of different Qt versions shares the same file name, I cannot put them in one fold (the fold of .exe file exactly). I put my Own Qt version library files there, so the dynamic library developed with other Qt version cannot be used. What can I do to solve this problem?
@cliii said in Load dynamic library failed:
What can I do to solve this problem?
Compile the plugins and your program with the same version. Everything else can't work.
-
so use the same Qt version is the only solution? I cannot get the source code of the dll I need but the only compiled dll file.
Then use the exact same version the DLL was built with for your program.
-
It should also be possible to use a newer Qt version for your app - Qt is backwards compatible for major versions so a plugin compiled e.g. against Qt6.5 will properly work with Qt6.8 but not the other way round.
-
-
Then what should I do if I need to use two dynamic libraries developed by different Qt Version?
@cliii Read the answers you already have and apply them to the specifics of your situation.
You cannot mix Qt 5.x and Qt 6.x for example.
You cannot use a plugin from Qt 5.2 in a program built with Qt 5.15.
You cannot mix 32-bit and 64-bit libraries, even with identical Qt versions.
You cannot mix libraries built with Microsoft tools and those built with MingW. -
Hi, try to put the dll in a subfolder and then use this object to load it
QLibrary Library;
Library.setFileName("dir01/mydll.dll");
Please remember, if the dll requires its plugins, other dll or a particular msvc version you have to install all them@mrdebug You are just plain wrong - it's not possible to load e.g. two different QtCore dlls into one address space.
-
The only problem is different Qt versions have the same dll file names(Qt5Core.dll for example). If they are different names(Qt_5_12_Core.dll for one and Qt_5_2_Core.dll for another then I can put them in the same fold). Maybe i can try to change -lQt5Core to -lQt5Core1 in the Makefile of my own program and then change Qt5Core.dll to Qt5Core1.dll.
-
The only problem is different Qt versions have the same dll file names(Qt5Core.dll for example). If they are different names(Qt_5_12_Core.dll for one and Qt_5_2_Core.dll for another then I can put them in the same fold). Maybe i can try to change -lQt5Core to -lQt5Core1 in the Makefile of my own program and then change Qt5Core.dll to Qt5Core1.dll.
@cliii When it's a plugin - why do you need to link against it then?
Also, as I said you can not link agsinst two different version of the same library. -
So what's the real problem then? Simply link the library to your app and you're fine as long as you use the same or newer Qt5 version.