Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with Qt low-level dynamic plugins: The specified module could not be foundd
QtWS25 Last Chance

Problem with Qt low-level dynamic plugins: The specified module could not be foundd

Scheduled Pinned Locked Moved Unsolved General and Desktop
pluginsdynamic link
5 Posts 3 Posters 734 Views
  • 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.
  • U Offline
    U Offline
    uPrizZ
    wrote on last edited by uPrizZ
    #1

    Hello community,

    I have a program which loads .dll plugins at runtime similar to the "Echo Plugin" example in the Qt docs (https://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html). This has worked previously, but for some reason (it is possible that I made changes which broke the loader), it stopped working and now I am unable to load any plugins.

    Let me show you my interface first which is a part of my main application / main window:

    #ifndef PLUGININTERFACE_H
    #define PLUGININTERFACE_H
    
    #include <QtPlugin>
    
    // forward declarations
    class MainWindow;
    struct P3DData;
    
    class PluginInterface
    {
    public:
        //virtual ~PluginInterface() = 0;
        virtual bool createPublisher(MainWindow*, P3DData*) = 0;
    };
    
    #define PLUGIN_INTERFACE_iid "PluginInterface"
    Q_DECLARE_INTERFACE(PluginInterface, PLUGIN_INTERFACE_iid)
    
    #endif // PLUGININTERFACE_H
    

    I then load all plugins within the "/plugins" directory using the following method within my MainWindow class:

    bool MainWindow::loadPlugins()
    {
        QDir pluginsDir(qApp->applicationDirPath());
        pluginsDir.cd("plugins");
    
        const auto entryList = pluginsDir.entryList(QDir::Files);
        for(const QString &fileName : entryList)
        {
            QString dllPath = pluginsDir.absoluteFilePath(fileName);
    
            if(!fileName.contains(".dll")) continue;
    
            QPluginLoader* loader = new QPluginLoader(dllPath);
            loaderList.push_back(loader);     
            QObject *plugin = loader->instance();
    
            if (plugin)
            {
                qDebug() << "[PluginLoader] Lade" << fileName;
    
                pluginList.push_back(qobject_cast<PluginInterface *>(plugin));
                pluginList.last()->createPublisher(this, simDataPtr);
                pluginCount++;
    
                pushToLogBox("[PluginLoader] " + fileName + " wurde erfolgreich geladen!");
                continue;
            }
            else
            {
                pushToLogBox("[PluginLoader] Fehler: '" + fileName + "': " + loader->errorString());
                delete loaderList.takeLast(); // takeLast() entfernt im  auch automatisch den Eintrag im Vektor (im Gegensatz zu last())!
            }
        }
    
        updateUI();
    
        if(pluginCount > 0)
        {
            pushToLogBox(QString("[PluginLoader] Es wurden ") + QString(std::to_string(pluginCount).c_str()) + QString(" Plugin(s) geladen!"));
            return true;
        }
    
        pushToLogBox("[PluginLoader] Es konnte kein Plugin geladen werden!");
        return false;
    }
    

    The header of the main class of my plugin looks like that:

    #ifndef _POSITION_PUBLISHER_H_
    #define _POSITION_PUBLISHER_H_
    
    #include <QObject>
    #include <thread>
    
    #include <fastrtps/fastrtps_fwd.h>
    #include <fastrtps/publisher/PublisherListener.h>
    
    #include "PositionPubSubTypes.h"
    #include "MainWindow.h"
    
    using namespace eprosima::fastrtps;
    
    
    class PositionPublisher : public QObject, PluginInterface
    {
        Q_OBJECT
        Q_PLUGIN_METADATA(IID "PluginInterface")
        Q_INTERFACES(PluginInterface)
    
    public:
        PositionPublisher();
        ~PositionPublisher();
        bool createPublisher(MainWindow* _window, P3DData* _simDataPtr) override;
        // ....
    };
    
    #endif // _POSITION_PUBLISHER_H_
    

    In the .pro file of the plugin I also define "CONFIG += plugin".

    Now the problem when running the loadPlugins() method is, that it checks the correct Position.dll file, but loader->instance() returns null and the loader->errorString() looks as follows:

    Cannot load library F:\DEV\build\simNET\bin\plugins\Position.dll: The specified module could not be found

    As far as I can tell, my code matches pretty exactly the one from the Echo Plugin example, with the difference that my loadPlugins method is capable to load multiple plugins. What is the problem here?

    Thank you all very much.

    1 Reply Last reply
    0
    • U Offline
      U Offline
      uPrizZ
      wrote on last edited by
      #2

      push: I still have that problem

      1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Make sure that all Dependencies of Position.dll is in your PATH

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        2
        • U Offline
          U Offline
          uPrizZ
          wrote on last edited by uPrizZ
          #4

          I tried adding the following paths to my PATH env variable:

          The libraries the plugin depends on (path correct, I am also including these in my main application and that works fine)

          F:\Programme\Prepar3D v4\SDK\inc\SimConnect
          F:\Programme\Prepar3D v4\SDK\lib\SimConnect
          
          F:\DEV\prog\FastRTPSv1.5\include
          F:\DEV\prog\FastRTPSv1.5\lib\x64Win64VS2015
          

          The plugin folder, where the actual plugin is deployed to after compilation. The main application is in the bin folder

          F:\DEV\build\simNET\bin\plugins
          

          Still the same error...

          EDIT: Is it possible that something with my Qt installation is wrong or is that issue not connected to that?

          EDIT2: Btw I also tried to place the plugins in the bin folder, so in the same directory where my main application .exe is located, then changed the loadPlugins() method a little, so that it looks in the bin directory and the result is still the same again...

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Hi,

            You should start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It should show more information with regard to plugin loading.

            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
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved