Problems with Open-Source Downloads read and

[Moved] Q_EXPORT_PLUGIN2 and variables in TARGET

  • The documentation states:
    Q_EXPORT_PLUGIN2 ( PluginName, ClassName )

    bq. This macro exports the plugin class ClassName for the plugin specified by PluginName. The value of PluginName should correspond to the TARGET specified in the plugin's project file.

    However my TARGET contains variables like the architecture or debug/release mode.
    Is there anyway to handle this through $$qtLibraryTarget() or #ifdef ?

    [EDIT: fixed formatting, Volker]

  • qmake's variables are not available in the C++ preprocessor. You can define a macro in the qmake project file and export this to the precprocessor (just as -D on the command line would do). #ifdef is also an option.

    EDIT: moved to the Tools forum, as it's more a qmake issue.

  • Thanks for the format fix, and sorry if I posted in the wrong section.
    You say #ifdef is a solution, but is the Q_EXPORT_PLUGIN2 expanded when I run qmake on my pro file, or when moc'ing with visual studio?

  • It's a regular preprocessor macro, so it's expanded at compile time. It's possible that moc also recognizes it and generates some code.

    qmake does not expand the macros in the code; in fact you can create Qt projects without qmake (eg. with CMake or write the Makefiles manually).

  • It is strange that this macro looks like it's not using the PLUGIN var:
    const char * Q_STANDARD_CALL qt_plugin_query_verification_data()
    { return qt_plugin_verification_data; }

  • The actual definition of Q_EXPORT_PLUGIN2 depends on the value of QT_STATICPLUGIN. One of these uses the value of PLUGIN.

Log in to reply