Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Compiling plugin with mingw
I ran into a problem that my application uses plugins driven by Qt plugins engine. The application provides simple interface class, just like Qt Plugins tutorial says.
It works like a charm under Linux, but under Windows I have problem compiling plugins, because mingw (apparently all Windows compilers?) forces all symbols in plugin dll to be resolved at compile time. Why, oh, why?! All symbols will be resolved anyway when plugin gets loaded into the application.
Do I really need to go through entire application and mark symbols to be exported?
I already tried the fast way - I used dlltool to export all symbols from the exe file, but when I tried to compile plugin against generated .a file I received some linker error about duplicate mingw symbols... (looked like the exe file already has some symbols that dll tried to link again, or something like that).
Is this really a thing? Isn't there any simpler way to handle that?
Okay, so I did go through entire application and marked all symbols to be exported. Now I'm able to create proper *.a file and link plugins to it.
Mingw compiles and links plugins dll, but now I have this strange problem.
When I try to load the plugin, the plugin loader says that it cannot find some module.
I loaded the dll into the dependency checker tool and it showed me that the dll has unresolved dependencies to QtCored.dll, SQLiteStudio.exe, etc...
Those are dependencies that are already satisfied in SQLiteStudio.exe, which is loading this dll. Why doesn't it work?
All unsatisfied dependencies in dll are satisfied by the exe application.
Okay, problem solved.
I was copying plugin dependencies (dlls) into plugins directory, while I should have been copying them into the application directory, not plugins subdirectory. It's the application that resolves dependencies and its directory is considered as "current" for plugin dependencies.