Results 1 to 6 of 6

Thread: QLibrary::load: The specified module could not be found

  1. #1
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default QLibrary::load: The specified module could not be found

    Hello. I am using QLibrary to load a dll file on Windows 7 x64, but it fails with the error message "The specified module could not be found". WinAPI function LoadLibrary also fails, however, I can load it with
    Qt Code:
    1. LoadLibraryEx("C:\\Program Files (x86)\\VideoLAN\\VLC\\libvlc.dll", NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
    To copy to clipboard, switch view to plain text mode 
    so the problem is somehow related to the search strategy specified with LOAD_WITH_ALTERED_SEARCH_PATH flag. I'd like my code to be cross-platform, so I am trying to use Qt instead of WinAPI, but how can I make it work with QLibrary?
    Last edited by mentalmushroom; 27th September 2011 at 11:18. Reason: LoadLibrary => LoadLibraryEx

  2. #2
    Join Date
    Aug 2011
    Posts
    44
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows Symbian S60

    Default Re: QLibrary::load: The specified module could not be found

    Could you paste here those non-working code(the code using QLibrary and the code using LoadLibrary)?

  3. #3
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: QLibrary::load: The specified module could not be found

    Ok, here it is:
    Qt Code:
    1. #include <QtCore/QCoreApplication>
    2. #include <QLibrary>
    3.  
    4. #include <stdio.h>
    5. #include <windows.h>
    6.  
    7. #define MY_DLL_PATH "C:\\Program Files (x86)\\VideoLAN\\VLC\\libvlc.dll"
    8.  
    9. int main(int argc, char *argv[])
    10. {
    11. QCoreApplication a(argc, argv);
    12.  
    13. QLibrary qlib(MY_DLL_PATH);
    14. if (qlib.load())
    15. printf("loaded successfully with QLibrary\n");
    16. else printf("failed to load with QLibrary\n");
    17.  
    18. if (HMODULE hMod = LoadLibraryExA(MY_DLL_PATH, NULL, LOAD_WITH_ALTERED_SEARCH_PATH))
    19. printf("loaded successfully with LoadLibraryEx");
    20. else printf("failed to load with LoadLibraryEx");
    21.  
    22. return a.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Aug 2011
    Posts
    44
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows Symbian S60

    Default Re: QLibrary::load: The specified module could not be found

    Well I suspect you can't work this issue out by Qt API, i.e. keep your app cross-platform.
    I see the libvlc.dll problem is in that it has dependencies in the same directory(C:\Program Files (x86)\VideoLAN\VLC) which is not a part of default dll search paths.
    To make your app looking more cross-platform I would suggest you to call SetDllDirectory WinAPI and then load libvlc by using QLibrary:
    Qt Code:
    1. #if defined( Q_WS_WIN )
    2. SetDllDirectory( L"C:\\Program Files (x86)\\VideoLAN\\VLC" );
    3. #endif
    4.  
    5. QLibrary lib( "libvlc" );
    6.  
    7. if ( lib.load() )
    8. {
    9. qDebug() << "libvlc loaded";
    10. }
    11. else
    12. {
    13. qDebug() << "libvlc not loaded";
    14. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,728
    Thanks
    13
    Thanked 1,608 Times in 1,535 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QLibrary::load: The specified module could not be found

    I am not intimate with the VLC library, but here are some other possible options:
    • Explicitly load the other DLLs from the VLC directory before the main one.
    • Change directory to the VLC libs directory and load the main library (then change back). The current directory is in the Windows DLL search path so its dependencies should be found.

  6. #6
    Join Date
    Jun 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: QLibrary::load: The specified module could not be found

    Check both VLC DLLs and your main program built in same configuration (RELEASE or DEBUG). If your main program is in DEBUG configuration, VLC DLLs should also be in DEBUG configuration.

Similar Threads

  1. Replies: 32
    Last Post: 25th August 2012, 23:10
  2. Replies: 1
    Last Post: 18th December 2010, 11:05
  3. QMYSQL: The specified module could not be found
    By jonny_wonny in forum Qt Programming
    Replies: 0
    Last Post: 22nd November 2009, 01:28
  4. Replies: 4
    Last Post: 7th March 2006, 08:52
  5. Qlibrary
    By rianquinn in forum Qt Programming
    Replies: 5
    Last Post: 4th February 2006, 12:23

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.