Qt plugin error, message in load "cannot load library"

  • I use Qt 5.3.2 with msvc 2010, I have the following use case, create an interface class and this class is used in a Qt plugin, the program and plugins compile fine, but when I execute the program and this try instance or load plugins, mark "cannot load library ..., the specified module could not be found.
    This is header of Interface:

       class ServicesInterface{
        virtual ~ServicesInterface() {}
    virtual QString name()  = 0;
    virtual int port() = 0;
     Q_DECLARE_INTERFACE(ServicesInterface, "services.ServicesInterface");

    The header of plugin is this:

      class BusControllerPlugin : public QObject, public ServicesInterface{
         Q_PLUGIN_METADATA(IID "busControllerPlugin.ServicesInterface")

    And this is how I try to load and instantiate the plugins, in the main.cpp.

       QPluginLoader loader(pluginsDir.absoluteFilePath(fileName));
        qDebug() << "fileName: " << pluginsDir.absoluteFilePath(fileName);
        if(ServicesInterface *interface =          qobject_cast<ServicesInterface *>(loader->instance())) {
        connect(interface, SIGNAL(pluginSend(const DeviceMessage&)), this, SLOT(msgFromPlugin(const DeviceMessage&)));
          interfaces.append(interface);**strong text**
        qDebug()<<"error loading plugin:"<<loader.errorString()<<";metadata:"<<loader.metaData();

    I read many tutorials and I don't see difference, this system was compiled with Qt 5.2, but actually I use 5.3.2, and happens this, exist new guide or form to create and load plugins? Or I missed something.

    Pd. I not use Qt Creator, i compile with custom script, the compilation is fine.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you mean that you are using the plugin compiled with 5.2 with a 5.3.2 built project ?

Log in to reply

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