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. QLibrary Error: Cannot load library The specified module could not be found
Forum Updated to NodeBB v4.3 + New Features

QLibrary Error: Cannot load library The specified module could not be found

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.7k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MichaelH
    wrote on last edited by
    #1

    Hi guys,

    i am trying to load a dll library that i need for my project.
    I have tried to load the library in the following way:

    QLibrary lib;
    lib.setFileName(QDir("C:\\the_path\\lib.dll").absolutePath());
    lib.load();
    error_msg = lib.errorString();
    

    the error_msg string always contains the following:
    "Cannot load Library 'C:\the_path\lib.dll': The specified module could not be found."

    If i dont give it a valid path, it does also give me the same error, so i guess it somehow does not find the dll.
    But when i use QFile to open the file, the path works..

    No idea why it does not work, has anyone had similar issues?

    Btw, i use qcreator with cmake, mingw 64Bit and the DLL is also a 64bit DLL.

    JonBJ 1 Reply Last reply
    0
    • M MichaelH

      Hi guys,

      i am trying to load a dll library that i need for my project.
      I have tried to load the library in the following way:

      QLibrary lib;
      lib.setFileName(QDir("C:\\the_path\\lib.dll").absolutePath());
      lib.load();
      error_msg = lib.errorString();
      

      the error_msg string always contains the following:
      "Cannot load Library 'C:\the_path\lib.dll': The specified module could not be found."

      If i dont give it a valid path, it does also give me the same error, so i guess it somehow does not find the dll.
      But when i use QFile to open the file, the path works..

      No idea why it does not work, has anyone had similar issues?

      Btw, i use qcreator with cmake, mingw 64Bit and the DLL is also a 64bit DLL.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @MichaelH
      One possibility: a .DLL may be there/openable via plain QFile, but to load successfully via QLibrary::load() it must have (not only the correct architecture etc.) any/all its dependency DLLs found and loadable. If they are not found it may well be that the error message you get is "Cannot load Library '...': The specified module could not be found.", when in fact it ought really be "The library was found but could not be loaded because some of its dependencies are missing or incorrect".

      You can only use whatever the current Windows tool is which used to be called "Dependency Viewer/Walker" if you want to examine the .DLL to see whether some of its dependencies are missing.

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

        Hi,

        Did you check that the output of QDir("C:\\the_path\\lib.dll").absolutePath() is what you expect ?

        On a side note, you should use the forward slash notation for your paths. Qt handles the conversion for you while you use the framework and it's less error prone.

        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