PDA

View Full Version : Problem with a plugin which depends on another plugin



agarny
23rd June 2011, 21:11
Hi, I am trying to make my application as modular as possible by having everything as a plugin. Some of my plugins are self-contained (e.g. plugin A) while others are dependent on other plugins (e.g. plugin B depends on plugin A, more precisely B uses resources and classes which are defined in A).

Before building A and B as 'proper' plugins, I thought I would first build them as 'pure' shared libraries (note: in case it matters, I use CMake not QMake), and everything builds as expected and I can load A and B using QLibrary. If I use QPluginLoader, then obviously I get told that A and B are not Qt plugins.

The next step was for me to make A and B 'proper' plugins. I thought I would start with A and disable B, so that I could test the loading of A using QPluginLoader, and indeed everything works as expected and I can load A using QPluginLoader. Next, I made B a 'proper' plugin, but this time round it doesn't build... I get several undefined references to classes that are defined in A and which I need in B.

Now, could it be that I overlooked something? If so, what could it be? As I said, if I remove the plugin-specific side of things (i.e. Q_EXPORT_PLUGIN2) then everything builds and loads fine.

ChrisW67
24th June 2011, 00:25
Care to share some of the errors regarding undefined references? These are usually the result of broken library requirements or search paths... but we could guess forever.

agarny
24th June 2011, 12:30
Yes, sorry about that. Here is the kind of undefined references I get:


Linking CXX shared library ..\..\..\..\Viewer.dll
Creating library file: ..\..\..\..\libViewer.dll.a
CMakeFiles\ViewerPlugin.dir/objects.ammlviewerwidget.cpp.obj):mmlviewerwidget. cpp:(.text+0xd9): undefined reference to `QtMmlWidget::paintEvent(QPaintEvent*)’
CMakeFiles\ViewerPlugin.dir/objects.a(mmlviewerwidget.cpp.obj):mmlviewerwidget .cpp:(.text+0×11b): undefined reference to `OpenCOR::CommonWidget::drawBorderIfDocked(bool const&, bool const&, bool const&, bool const&, bool const&)’
…
collect2: ld returned 1 exit status
mingw32-make2: *** [Viewer.dll] Error 1
mingw32-make1: *** [src/plugins/edit/Viewer/CMakeFiles/ViewerPlugin.dir/all] Error 2
mingw32-make: *** [all] Error 2Otherwise, and as I mentioned in my original message, everything works fine if I disable the plugin aspect of my code.

pan
24th June 2011, 12:45
I'm no expert in this. But to use my plugins as a library I followed this technique:

http://doc.qt.nokia.com/4.7-snapshot/sharedlibrary.html

worked for me...

agarny
24th June 2011, 19:30
I'm no expert in this. But to use my plugins as a library I followed this technique:

http://doc.qt.nokia.com/4.7-snapshot/sharedlibrary.html

worked for me...... and it is for me too! So, yes, thanks a lot indeed! I guess I didn't expect this to be required since building my various moduled as 'pure' shared libraries was fine. It was just when I was trying to build them as plugins that it wasn't. Anyway, now everything's fine and that's what matters! :)