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. MySQL plugin, mingw64 and Windows 8.1 - QMYSQL driver not loaded
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved General and Desktop
17 Posts 4 Posters 5.4k Views 2 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.
  • AggsA Aggs

    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.

    the_T Offline
    the_T Offline
    the_
    wrote on last edited by the_
    #5

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

    -- No support in PM --

    1 Reply Last reply
    0
    • SGaistS SGaist

      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.

      AggsA Offline
      AggsA Offline
      Aggs
      wrote on last edited by
      #6

      @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.

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

        Which version did you install exactly ?

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

        AggsA 1 Reply Last reply
        0
        • SGaistS SGaist

          Which version did you install exactly ?

          AggsA Offline
          AggsA Offline
          Aggs
          wrote on last edited by
          #8

          @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
          
          
          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #9

            I meant where did you get that package ?

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

            AggsA 1 Reply Last reply
            0
            • SGaistS SGaist

              I meant where did you get that package ?

              AggsA Offline
              AggsA Offline
              Aggs
              wrote on last edited by
              #10

              @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)

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

                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 ?

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

                AggsA 1 Reply Last reply
                0
                • SGaistS SGaist

                  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 ?

                  AggsA Offline
                  AggsA Offline
                  Aggs
                  wrote on last edited by
                  #12

                  @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.

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

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

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

                    AggsA 1 Reply Last reply
                    0
                    • SGaistS SGaist

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

                      AggsA Offline
                      AggsA Offline
                      Aggs
                      wrote on last edited by
                      #14

                      @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.

                      AggsA 1 Reply Last reply
                      0
                      • AggsA Aggs

                        @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.

                        AggsA Offline
                        AggsA Offline
                        Aggs
                        wrote on last edited by
                        #15

                        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?

                        1 Reply Last reply
                        0
                        • AggsA Offline
                          AggsA Offline
                          Aggs
                          wrote on last edited by
                          #16

                          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)

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

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

                            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