Load dynamic library failed
-
wrote on 11 Oct 2024, 05:44 last edited by
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.
-
wrote on 11 Oct 2024, 06:10 last edited by
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.
-
Lifetime Qt Championwrote on 11 Oct 2024, 06:13 last edited by aha_1980 10 Nov 2024, 06:14
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.
-
Lifetime Qt Championwrote on 11 Oct 2024, 06:19 last edited by Christian Ehrlicher 10 Nov 2024, 06:19
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.
-
wrote on 11 Oct 2024, 06:22 last edited by
Then what should I do if I need to use two dynamic libraries developed by different Qt Version?
-
wrote on 11 Oct 2024, 06:41 last edited by
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 -
Then what should I do if I need to use two dynamic libraries developed by different Qt Version?
wrote on 11 Oct 2024, 06:45 last edited by@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.
-
wrote on 11 Oct 2024, 07:07 last edited by
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.
-
wrote on 11 Oct 2024, 07:11 last edited by
The dll you have to use what it is for?
-
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. -
wrote on 11 Oct 2024, 08:41 last edited by
It is not a Qt plugin, just a common dynamic library, use .lib and .dll file to link
-
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.
4/14