MySQL plugin, mingw64 and Windows 8.1 - QMYSQL driver not loaded



  • I'm trying to make a Windows application that uses the Qt SQL plugin. With mingw32 this works fine, but when I try to build it as a 64bit application with mingw64 I get the following error:

    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QIBASE QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    QSqlError("", "Driver not loaded", "Driver not loaded")
    

    With the QT_DEBUG_PLUGINS flag set I get:

    loaded library "C:/msys64/mingw64/share/qt5/plugins/sqldrivers/qsqlmysqld.dll"
    QLibraryPrivate::loadPlugin failed on "C:/msys64/mingw64/share/qt5/plugins/sqldrivers/qsqlmysqld.dll" : "Cannot load library C:\\msys64\\mingw64\\share\\qt5\\plugins\\sqldrivers\\qsqlmysqld.dll: The specified module could not be found."
    QSqlDatabase: QMYSQL driver not loaded
    

    Trying to load qsqlmysqld.dll with LoadLibraryExA fails unless the DONT_RESOLVE_DLL_REFERENCES flag is used.

    Looking at qsqlmysqld.dll in Dependency walker only flags the following two missing libs:
    API-MS-WIN-CORE-SHUTDOWN-L1-1-1.DLL
    EXT-MS-WIN-NTUSER-UICONTEXT-EXT-L1-1-0.DLL

    However I have no idea what these libs do, where the come from or why they are missing.

    So my questions are:

    1. Are the above 'missing' dlls important?
    2. If so, where are they?
    3. If not, why dosn't the MySQL plugin work?
    4. Any other thoughts/suggestions?

    Also, libmysql.dll - this is located in the same folder as the executable, is a 64bit version and loads successfully with LoadLibraryExA so libmysql.dll doesn't seem to be the problem.



  • you Should copy 'libmysql.dll' inside app folder



  • @ARASHz4 I did - see the last sentence of the OP.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Did you build both debug and release version of Qt ?

    The error message says that it can't find qsqlmysqld.dll which is the debug version of the plugin.



  • @Aggs
    /DELETED/ @SGaist was a bit faster with the same question :)



  • @SGaist I didn't build Qt - I just downloaded the pre-compiled binary.

    I have been building my application in debug mode - which I assume is why qsqlmysqld.dll is been used.

    I just tried building a release version and it results in all the same errors but with qsqlmysql.dll instead.


  • Lifetime Qt Champion

    Which version did you install exactly ?



  • @SGaist The details from Qt Creator's option menu:

    
    Name: Qt 5.6.0 (mingw64)
    ABI: x86-windows-msys-pe-64bit
    Source: C:\msys64\mingw64
    mkspec: win32-g++
    qmake: C:\msys64\mingw64\bin\qmake.exe
    Default: debug
    Version: 5.6.0
    QMAKE_SPEC win32-g++
    QMAKE_VERSION 3.0
    QMAKE_XSPEC win32-g++
    QT_HOST_BINS C:\msys64\mingw64\bin
    QT_HOST_DATA C:\msys64\mingw64\share\qt5
    QT_HOST_LIBS C:\msys64\mingw64\lib
    QT_HOST_PREFIX C:\msys64\mingw64
    QT_INSTALL_ARCHDATA C:\msys64\mingw64\share\qt5
    QT_INSTALL_BINS C:\msys64\mingw64\bin
    QT_INSTALL_CONFIGURATION 
    QT_INSTALL_DATA C:\msys64\mingw64\share\qt5
    QT_INSTALL_DEMOS C:\msys64\mingw64\share\qt5\examples
    QT_INSTALL_DOCS C:\msys64\mingw64\share\qt5\doc
    QT_INSTALL_EXAMPLES C:\msys64\mingw64\share\qt5\examples
    QT_INSTALL_HEADERS C:\msys64\mingw64\include
    QT_INSTALL_IMPORTS C:\msys64\mingw64\share\qt5\imports
    QT_INSTALL_LIBEXECS C:\msys64\mingw64\share\qt5\bin
    QT_INSTALL_LIBS C:\msys64\mingw64\lib
    QT_INSTALL_PLUGINS C:\msys64\mingw64\share\qt5\plugins
    QT_INSTALL_PREFIX C:\msys64\mingw64
    QT_INSTALL_QML C:\msys64\mingw64\share\qt5\qml
    QT_INSTALL_TESTS C:\msys64\mingw64\share\qt5\tests
    QT_INSTALL_TRANSLATIONS C:\msys64\mingw64\share\qt5\translations
    QT_SYSROOT 
    QT_VERSION 5.6.0
    
    

  • Lifetime Qt Champion

    I meant where did you get that package ?



  • @SGaist Oh, I used MSYS2 to install it with the command: pacman -Sy mingw-w64-{i686,x86_64}-qt5

    Qt Creator is the GPL Windows version from the main site. (this is 32bit which I thought might cause problems but everything else seems to work - I can compile and run 64bit applications that don't use MySQL)


  • Lifetime Qt Champion

    For Qt Creator, no there's no influence. It only uses Qt, the architecture of it is of no importance for the functionality (unless of course you are building a plugin for it)

    Silly question but: do you have a MinGW64 build of MySQL available on your machine ?



  • @SGaist I don't have MySQL database installed on this machine (as I have another machine setup as a server with it)

    I have a 64bit version of MySQL Workbench which was installed from the pre-compiled binaries. This contains the 64bit libmysql.dll which I am using.

    Somehow I also have a 32bit version of libmysql.dll although I'm not quite sure where this came from. I've been using it for some time as it works when I compile a 32bit version of my application.


  • Lifetime Qt Champion

    Then I wonder if the 32bit version of libmysql is found before the 64bit version.



  • @SGaist I don't think so. When I remove the 32bit libmysql.dll file the 32bit version of my app stops working but the 64bit version still doesn't work.

    And when:
    LoadLibraryExA("libmysql.dll", NULL, NULL);
    is called, it successfully loads the library on both the 32bit and 64bit versions of my app.



  • This is the dependences from qsqlmysql.dll (http://imgur.com/MUMHGfN)

    Just noticed that it seems a bit odd that libmariadb.dll is needed but libmysql.dll isn't?



  • And that was the problem. I added libmariadb.dll to the same folder as the executable (same place as libmysql.dll) and now it all works!

    Why I need a MariaDB library to connect to a MySQL database is still a mystery to me though... In fact libmysql.dll isn't even used - I just removed it and it still works.

    Thanks for the help anyway! (if I can work out how, I'll mark this thread as solved)


  • Lifetime Qt Champion

    MariaDB is a drop-in replacement for MySQL and AFAIK, you should be able to connect to MySQL servers through the MariaDB client libraries.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.