Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Unable to load plugins by QPluginLoader because of unavailability of shared libraries
Forum Update on Monday, May 27th 2025

Unable to load plugins by QPluginLoader because of unavailability of shared libraries

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
10 Posts 3 Posters 3.1k 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
    Uday More
    wrote on last edited by
    #1

    Hello,
    I am deploying an application where I have a "Plugins" folder and all the dependent shared libraries are kept in the Plugins folder.
    When I run the program, I get the following error, "Cannot load library $library_name. The specified module could not be found".
    The reason for this is because, the shared libraries aren't in the application directory path and hence the plugins aren't successful in loading.
    I've tried all possible solutions like qputenv, qt.conf and addLibraryPath, but was not successful. Please anyone can guide me for the following or can i consider the solution of placing allthe plugins and shared libraries in the executable folder.
    Thanks.

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

      Hi and welcome to devnet,

      What version of Qt are you using ?
      On what OS ?
      Where are the dependencies located ?
      How are you deploying your application ?

      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
      0
      • U Offline
        U Offline
        Uday More
        wrote on last edited by
        #3
        1. QT version : 5.7
        2. Windows 7
        3. AppFolder contains app.exe
          --Plugins contains Viewer.dll(plugin), and other dependent dlls.

        I want to add the AppFolder/Plugins folder to PATH variable at runtime. I tried using qputenv, qt.conf and addLibraryPath ways of doing but eventually the the same runtime error comes.

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

          Can you show your .pro file ?

          Did you check with a tool like Dependency Walker to check if you have anything missing ?

          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
          0
          • U Offline
            U Offline
            Uday More
            wrote on last edited by
            #5

            Yes I checked with dependency walker. I resolved those dependencies by placing all the libraries in the AppFolder/Plugins directory where the Viewer.dll exists. Still I was facing the same issue. Eventually I had to remove all the dependencies of Viewer.dll and put in the AppFolder.
            From this what I understand is even if the shared libraries for a plugin are in a separate directory from the AppFolder, it will not work. They have to be put in the AppFolder to work.

            Now my question all remains the same.
            How do we add this AppFolder/Plugins to PATH variable at runtime so that the folders other than AppFolder are recognized by the application?

            @SGaist . Hope you understand I cannot share the .pro file.

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

              Take a look at QCoreApplication::addLibraryPath. Looks like what you need.

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

              U 1 Reply Last reply
              1
              • SGaistS SGaist

                Take a look at QCoreApplication::addLibraryPath. Looks like what you need.

                U Offline
                U Offline
                Uday More
                wrote on last edited by
                #7

                @SGaist I tried the same as mentioned earlier. It even adds to the PATH variable when printed with "QString QCoreApplication::applicationDirPath()". But it seems that the Application is not able to recognize the added directory to PATH once the QApplication instance is created. I tried placing the statement "QCoreApplication::addLibraryPath" before the instance is created, but it gives error that first the QApplication instance must be created which is very much true.
                My library "Viewer.dll" is loaded by QPluginLoader.

                jsulmJ 1 Reply Last reply
                0
                • U Uday More

                  @SGaist I tried the same as mentioned earlier. It even adds to the PATH variable when printed with "QString QCoreApplication::applicationDirPath()". But it seems that the Application is not able to recognize the added directory to PATH once the QApplication instance is created. I tried placing the statement "QCoreApplication::addLibraryPath" before the instance is created, but it gives error that first the QApplication instance must be created which is very much true.
                  My library "Viewer.dll" is loaded by QPluginLoader.

                  jsulmJ Online
                  jsulmJ Online
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @Uday-More said in Unable to load plugins by QPluginLoader because of unavailability of shared libraries:

                  QCoreApplication::addLibraryPath

                  Did you try to call it before QCoreApplication instance is created?

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  U 1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @Uday-More said in Unable to load plugins by QPluginLoader because of unavailability of shared libraries:

                    QCoreApplication::addLibraryPath

                    Did you try to call it before QCoreApplication instance is created?

                    U Offline
                    U Offline
                    Uday More
                    wrote on last edited by
                    #9

                    @jsulm Yes I tried to call before the QCoreApplication instance is created. But i get the error to first instantiate the QCoreApplication and then add the library path.
                    Secondly I did it after the instance is created, and after printing the latest library paths, I could see there. But eventually the run time error "Cannot load library $library_name. The specified module could not be found" still persists.

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

                      This MSDN entry might be of interest.

                      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
                      0

                      • Login

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