Hello, I found problem in current plugin loader & plugins and need help how to solve it.
My current code have common "interface" classes for password and addressbook plugins. Because trojita working only with pointers of these common objects, code of interface classes must be statically linked into trojita executable binary. But plugin implementation inherit from common interface class, so constructor (and other qobject moc methods) must be accessible from plugin shared library. So there are two possible methods: 1. static link code of interface classes to both trojita executable and to plugin shared library 2. link interface code only to trojita executable and export symbols to be accessible by loaded libraries My current code using option 1. because it does not need any hacks to cmake. But now I see that sometimes (when compiled as kontact shared library) qobject_cast<> from QObject* to PasswordInterface* provided by plugin not working and returning NULL. This cause that plugin is ignored as incompatible. But dynamic_cast<> operator working fine. Is this because both trojita executable and password plugin has linked code of PasswordInterface class? I tried to rewrite cmake code to use option 2. It also needed to add more Q_DECL_IMPORT/EXPORT to current code... But cmake code needs ugly hack -Wl,-whole-archive as somebody wrote here http://stackoverflow.com/questions/6054942/gcc-rdynamic-not-working-with-static-libraries and here http://www.mail-archive.com/cmake@cmake.org/msg01890.html (plus some other cmake functions and properties - but all portable for cmake) Now I tried to compile trojita code to shared library for loading by KDE4 Kontact. But Kontact loading plugins without RTLD_GLOBAL and when Trojita started to loading its plugins, every plugin failed because of resolving some symbols (used by plugin which should export trojita shared library). I looked into Kontact code how loading plugins and it is not possible to add RTLD_GLOBAL flag (or QLibrary::ExportExternalSymbolsHint). This happen with option 2. When I used option 1 with dynamic_cast<> plugins worked fine. But qobject_cast<> not. So questions are: * what to do with c++ code which is part of plugin interfaces? Use option 1? * how to solve issue when trojita is compiled as shared library (e.g. kontact kpart), started by other process (kontact) and needs to loads its plugins (trojita kwallet plugin)? -- Pali Rohár pali.ro...@gmail.com
signature.asc
Description: This is a digitally signed message part.