My application can load plugins. Plugins can use symbols from the main executable.
It is written in C++ with Qt. I'm using the qmake to build it.
Under Linux there's a weak linking, which allows my plugins to be compiled and linked without satisfying all symbol dependencies (which will be provided by the loading application at runtime anyway).
Windows requires all symbols to be satisfied. I managed to do that with mingw32 with help of -Wl,--export-all-symbols,--out-implib,libMyApp.a, which produces a table of symbols from the executable to be used by the linker when linking the plugin.
Now I've got a problem with MacOS X. I don't know how to deal with it. I found at Apple's help here that I should compile my plugin not with -dynamiclib, but instead I should use -bundle -bundle_loader MyApp. Problem is that qmake forces -dynamiclib and I don't know how to disable it. I also don't know if using this "bundle" options will help with my problem.
What is the proper way to build such plugin using qmake?
EDIT/UPDATE:
I use qmake from within QtCreator. The -dynamiclib is provided (and forced) by qmake automatically when compiling a TEMPLATE = lib. When the -dynamiclib is provided to the compiler, it says I cannot use -bundle_loader together with -dynamiclib. The message stands that it's forbidden. Therefore I'm looking for a way to remove that -dynamiclib.
Yes, I have read the qmake manual. Not "word by word", but generally I've looked for my problem in there, with no luck.
I use Qt/qmake 5.3.1, QtCreator shipped together with Qt package (3.1.2).
From here
When using the lib template, the following options can be added to the CONFIG variable to determine the type of library that is built:
plugin - The library is a plugin; this also enables the dll option.
So, try to add into your .pro file
macx:{ CONFIG += plugin QMAKE_LFLAGS_SHLIB -= -dynamiclib QMAKE_LFLAGS_PLUGIN -= -dynamiclib QMAKE_LFLAGS_PLUGIN += -bundle }
Similarly you can control compilation flag for your project.
Additional information about qmake variables can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With