PDA

View Full Version : [SOLVED] Q_EXPORT_PLUGIN2 vs. $$qtLibraryTarget()



zaphod.b
24th July 2009, 14:43
Hi all,

I have a plugin foo that I build to TARGET = $$qtLibraryTarget(foo). This implies that under Windows, the debug plugin is named food.dll (mark the trailing 'd' character).

I use Q_EXPORT_PLUGIN2(PluginName, FooClass) to export the plugin class. As the doc (http://doc.trolltech.com/4.5/qtplugin.html#Q_EXPORT_PLUGIN2) states:
The value of PluginName should correspond to the TARGET specified in the plugin's project file.
So the 1st parameter to Q_EXPORT_PLUGIN2 needs to fit the appropriate build configuration.
Of course I could use #ifdef to preprocess with a different macro parameter depending on the configuration. However, I dislike this option as it requires manual synchronization between plugin implementation source and .pro file.

Is there a better way to automagically adopt Q_EXPORT_PLUGIN2's PluginName to the TARGET?

Thank you for your help and proposals.

jpn
24th July 2009, 15:11
I think using "foo"in Q_EXPORT_PLUGIN2() should be fine.

For example the GIF image format plugin of Qt does it like this:

gif.pro:


TARGET = qgif
include(../../qpluginbase.pri)

qpluginbase.pri:


TARGET = $$qtLibraryTarget($$TARGET)

main.cpp:


Q_EXPORT_PLUGIN2(qgif, QGifPlugin)

zaphod.b
24th July 2009, 15:40
Thx jpn, you're right.

My build environment was in a state where I could only load the plugin when I put the trailing 'd' to PluginName in Q_EXPORT_PLUGIN2. Maybe some plugin cache issue?

Anyway, i did a major cleanup and everything works as expected. No need to take care of the configuration there explicitly.

Sorry for stirring up.