Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

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

    General and Desktop
    qtplugin
    2
    2
    2478
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Arturo Pablo R last edited by

      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{
      
        public:
          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_OBJECT
           Q_PLUGIN_METADATA(IID "busControllerPlugin.ServicesInterface")
            Q_INTERFACES(ServicesInterface)  
          public:
           BusControllerPlugin();
          ~BusControllerPlugin();
       }
      

      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);
      
          loader.load();
          if(ServicesInterface *interface =          qobject_cast<ServicesInterface *>(loader->instance())) {
          connect(interface, SIGNAL(pluginSend(const DeviceMessage&)), this, SLOT(msgFromPlugin(const DeviceMessage&)));
      
            interfaces.append(interface);**strong text**
           }
        else{
          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.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • First post
          Last post