Plug-ins developed with different compilers to host application compiler



  • I have an application developed with Qt 4.8.4 for VC2008. Application can be extended with plug-ins. I know these:

    bq. QPluginLoader checks that a plugin is linked against the same version of Qt as the application.

    bq. Plugins linked with a Qt library that has a higher version number will not be loaded by a library with a lower version number.

    bq. Plugins linked with a Qt library that has a lower major version number will not be loaded by a library with a higher major version number.

    Also I know plugins are built using a "Build Key":http://qt-project.org/doc/qt-4.8/deployment-plugins.html#the-build-key

    I have not yet tested, but I think Qt 4.8.4 in release configuration will produce binary compatible code between VC2008, VC2010, VC2012 (... and MinGW ?). Also I think this assumption is valid for different versions of GCC compiler.

    Now the problem is: let's say in interface class I have something like this
    @
    QWidget* createWidget(QWidget* parent) = 0
    @

    Plug-ins must implement this functions, with something like this

    @
    QWidget* createWidget(QWidget* parent)
    {
    return new QWidget(parent);
    }
    @

    Now when parent will be destroyed, plug-in's widget will be deleted with operator delete from VC2008. But if plug-in is developed with VC2010 the widget will be created with operator new from VC2010. From what I know this leads to memory corruption.

    Other solution would be to add other function in interface class
    @
    void destroyWidget(QWidget* widget) = 0
    @

    Now plug-ins must implement this function and widget will be destroyed with operator delete with which it was implemented. But this "hack" require more functions in interface class.

    So ... what do you think ? Which one would be the best solution in your opinion ?



  • Anyone has an idea about a possible memory corruption in this issue ?


  • Moderators

    It's my understanding that the app and its plugins need to be created with the exact same version of the compiler. I don't think your assertion about compatibility between the different VC compilers is necessarily correct. And pretty certain that there isn't compatibility at all between VC and MinGW.



  • [quote author="mlong" date="1363362056"]And pretty certain that there isn't compatibility at all between VC and MinGW.[/quote]

    This is certainly true.

    But I remember that I read somewhere, I do not have the link now, that VC 2008 ad VC 2010 are binary compatible. Maybe I wrong. However "this C++ DLL plugin interface explanation":http://stackoverflow.com/questions/4756944/c-dll-plugin-interface/4757105#4757105 is that somehow what I said in the first comment.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.