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. What is current (2019) recommended process (complete) for building a MySQL Driver for use with Qt on Windows?

What is current (2019) recommended process (complete) for building a MySQL Driver for use with Qt on Windows?

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 4 Posters 2.3k 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.
  • J Offline
    J Offline
    James Hankins
    wrote on last edited by
    #1

    I'm trying to sift through the many and aging recommendations of how to successfully build a mysql driver for Qt.

    I sorted through the process for MacOS using this post:
    https://forum.qt.io/topic/106565/mysql-qt-create-plugin-mysql-for-qt-on-mac and got things working there. Now I'm on to Windows and I'm stuck.

    Documentation here: https://doc.qt.io/qt-5/sql-driver.html#qmysql
    Seems to indicate using libmysql with embedded server. It would be wonderfully helpful if someone could specific the link for what needs to be installed from Mysql site.

    I'm seeing references from 2016 that state libmysql is being removed in version 8 which is the current version: https://mysqlserverteam.com/mysql-8-0-retiring-support-for-libmysqld/

    Any help appreciated. The documentation, at least to me, seems to be missing key steps. Given the number of queries on this topic, I must not be alone in this camp. I'm new to Qt so that makes life a little more confusing.

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

      Hi,

      What exact error are you getting ?

      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
      • J Offline
        J Offline
        James Hankins
        wrote on last edited by
        #3

        Hi,

        Using Mysql C++ Connector 8 from link https://dev.mysql.com/get/Downloads/Connector-C++/mysql-connector-c++-8.0.17-winx64.msi

        D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins>cd sqldrivers

        D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="C:\Program Files\MySQL\Connector C++ 8.0\include" "MYSQL_LIBDIR=C:\Program Files\MySQL\Connector C++ 8.0\lib64"

        Running configuration tests...
        Done running configuration tests.

        Configure summary:

        Qt Sql Drivers:
        DB2 (IBM) .............................. no
        InterBase .............................. no
        MySql .................................. no
        OCI (Oracle) ........................... no
        ODBC ................................... yes
        PostgreSQL ............................. no
        SQLite2 ................................ no
        SQLite ................................. yes
        Using system provided SQLite ......... no
        TDS (Sybase) ........................... no

        Qt is now configured for building. Just run 'nmake'.
        Once everything is built, you must run 'nmake install'.
        Qt will be installed into 'D:\Users\jhankins\Qt\5.13.1\msvc2017_64'.

        Prior to reconfiguration, make sure you remove any leftovers from
        the previous build.

        D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>nmake sub-mysql

        Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
        Copyright (C) Microsoft Corporation. All rights reserved.

        NMAKE : fatal error U1073: don't know how to make 'sub-mysql'
        Stop.

        Using commercial install of Qt not built from source.

        1 Reply Last reply
        0
        • J Offline
          J Offline
          James Hankins
          wrote on last edited by
          #4

          I have also tried Mysql Server 64 bit from:

          https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.17-winx64.zip

          D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR="D:\Users\jhankins\Documents\mysql-8.0.17-winx64\mysql-8.0.17-winx64\include" MYSQL_LIBDIR="D:\Users\jhankins\Documents\mysql-8.0.17-winx64\mysql-8.0.17-winx64\lib"

          Running configuration tests...
          Done running configuration tests.

          Configure summary:

          Qt Sql Drivers:
          DB2 (IBM) .............................. no
          InterBase .............................. no
          MySql .................................. no
          OCI (Oracle) ........................... no
          ODBC ................................... yes
          PostgreSQL ............................. no
          SQLite2 ................................ no
          SQLite ................................. yes
          Using system provided SQLite ......... no
          TDS (Sybase) ........................... no

          Qt is now configured for building. Just run 'nmake'.
          Once everything is built, you must run 'nmake install'.
          Qt will be installed into 'D:\Users\jhankins\Qt\5.13.1\msvc2017_64'.

          Prior to reconfiguration, make sure you remove any leftovers from
          the previous build.

          D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>nmake sub-mysql

          Microsoft (R) Program Maintenance Utility Version 14.16.27034.0
          Copyright (C) Microsoft Corporation. All rights reserved.

          NMAKE : fatal error U1073: don't know how to make 'sub-mysql'
          Stop.

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by Christian Ehrlicher
            #5

            @james-hankins said in What is current (2019) recommended process (complete) for building a MySQL Driver for use with Qt on Windows?:

            Running configuration tests...
            Done running configuration tests.

            As you can see no config tests a run. This is due to the fact that you already called qmake in there and qmake caches it's results. Therefore you have to delete config.cache and run qmake again. qmake also says it (in imo not very good wording): "Prior to reconfiguration, make sure you remove any leftovers from the previous build."

            Here my output (with the existing config.cache file)

            D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>D:\CraftRoot\build\libs\qt5\qtbase\qt5-dev\bin\qmake.exe --
            
            Running configuration tests...
            Checking for DB2 (IBM)... no
            Checking for InterBase... no
            Checking for MySQL... no
            Checking for OCI (Oracle)... no
            Checking for ODBC... yes
            Checking for PostgreSQL... no
            Checking for SQLite (version 2)... no
            Checking for TDS (Sybase)... no
            Done running configuration tests.
            
            Configure summary:
            
            Qt Sql Drivers:
              DB2 (IBM) .............................. no
              InterBase .............................. no
              MySql .................................. no
              OCI (Oracle) ........................... no
              ODBC ................................... yes
              PostgreSQL ............................. no
              SQLite2 ................................ no
              SQLite ................................. yes
                Using system provided SQLite ......... no
              TDS (Sybase) ........................... no
            
            Qt is now configured for building. Just run 'nmake'.
            Once everything is built, Qt is installed.
            You should NOT run 'nmake install'.
            Note that this build cannot be deployed to other machines or devices.
            
            Prior to reconfiguration, make sure you remove any leftovers from
            the previous build.
            
            
            D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>D:\CraftRoot\build\libs\qt5\qtbase\qt5-dev\bin\qmake.exe -- MYSQL_INCDIR=D:/CraftRoot/download/mysql-8.0.17-winx64/include "MYSQL_LIBDIR=D:/CraftRoot/download/mysql-8.0.17-win
            x64/lib"
            
            Running configuration tests...
            Done running configuration tests.
            
            Configure summary:
            
            Qt Sql Drivers:
              DB2 (IBM) .............................. no
              InterBase .............................. no
              MySql .................................. no
              OCI (Oracle) ........................... no
              ODBC ................................... yes
              PostgreSQL ............................. no
              SQLite2 ................................ no
              SQLite ................................. yes
                Using system provided SQLite ......... no
              TDS (Sybase) ........................... no
            
            Qt is now configured for building. Just run 'nmake'.
            Once everything is built, Qt is installed.
            You should NOT run 'nmake install'.
            Note that this build cannot be deployed to other machines or devices.
            
            Prior to reconfiguration, make sure you remove any leftovers from
            the previous build.
            
            
            D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>del config.cache
            
            D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>D:\CraftRoot\build\libs\qt5\qtbase\qt5-dev\bin\qmake.exe -- MYSQL_INCDIR=D:/CraftRoot/download/mysql-8.0.17-winx64/include "MYSQL_LIBDIR=D:/CraftRoot/download/mysql-8.0.17-win
            x64/lib"
            
            Running configuration tests...
            Checking for DB2 (IBM)... no
            Checking for InterBase... no
            Checking for MySQL... yes
            Checking for OCI (Oracle)... no
            Checking for ODBC... yes
            Checking for PostgreSQL... no
            Checking for SQLite (version 2)... no
            Checking for TDS (Sybase)... no
            Done running configuration tests.
            
            Configure summary:
            
            Qt Sql Drivers:
              DB2 (IBM) .............................. no
              InterBase .............................. no
              MySql .................................. yes
              OCI (Oracle) ........................... no
              ODBC ................................... yes
              PostgreSQL ............................. no
              SQLite2 ................................ no
              SQLite ................................. yes
                Using system provided SQLite ......... no
              TDS (Sybase) ........................... no
            
            Qt is now configured for building. Just run 'nmake'.
            Once everything is built, Qt is installed.
            You should NOT run 'nmake install'.
            Note that this build cannot be deployed to other machines or devices.
            
            Prior to reconfiguration, make sure you remove any leftovers from the previous build.
            

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            J 1 Reply Last reply
            1
            • Christian EhrlicherC Christian Ehrlicher

              @james-hankins said in What is current (2019) recommended process (complete) for building a MySQL Driver for use with Qt on Windows?:

              Running configuration tests...
              Done running configuration tests.

              As you can see no config tests a run. This is due to the fact that you already called qmake in there and qmake caches it's results. Therefore you have to delete config.cache and run qmake again. qmake also says it (in imo not very good wording): "Prior to reconfiguration, make sure you remove any leftovers from the previous build."

              Here my output (with the existing config.cache file)

              D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>D:\CraftRoot\build\libs\qt5\qtbase\qt5-dev\bin\qmake.exe --
              
              Running configuration tests...
              Checking for DB2 (IBM)... no
              Checking for InterBase... no
              Checking for MySQL... no
              Checking for OCI (Oracle)... no
              Checking for ODBC... yes
              Checking for PostgreSQL... no
              Checking for SQLite (version 2)... no
              Checking for TDS (Sybase)... no
              Done running configuration tests.
              
              Configure summary:
              
              Qt Sql Drivers:
                DB2 (IBM) .............................. no
                InterBase .............................. no
                MySql .................................. no
                OCI (Oracle) ........................... no
                ODBC ................................... yes
                PostgreSQL ............................. no
                SQLite2 ................................ no
                SQLite ................................. yes
                  Using system provided SQLite ......... no
                TDS (Sybase) ........................... no
              
              Qt is now configured for building. Just run 'nmake'.
              Once everything is built, Qt is installed.
              You should NOT run 'nmake install'.
              Note that this build cannot be deployed to other machines or devices.
              
              Prior to reconfiguration, make sure you remove any leftovers from
              the previous build.
              
              
              D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>D:\CraftRoot\build\libs\qt5\qtbase\qt5-dev\bin\qmake.exe -- MYSQL_INCDIR=D:/CraftRoot/download/mysql-8.0.17-winx64/include "MYSQL_LIBDIR=D:/CraftRoot/download/mysql-8.0.17-win
              x64/lib"
              
              Running configuration tests...
              Done running configuration tests.
              
              Configure summary:
              
              Qt Sql Drivers:
                DB2 (IBM) .............................. no
                InterBase .............................. no
                MySql .................................. no
                OCI (Oracle) ........................... no
                ODBC ................................... yes
                PostgreSQL ............................. no
                SQLite2 ................................ no
                SQLite ................................. yes
                  Using system provided SQLite ......... no
                TDS (Sybase) ........................... no
              
              Qt is now configured for building. Just run 'nmake'.
              Once everything is built, Qt is installed.
              You should NOT run 'nmake install'.
              Note that this build cannot be deployed to other machines or devices.
              
              Prior to reconfiguration, make sure you remove any leftovers from
              the previous build.
              
              
              D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>del config.cache
              
              D:\CraftRoot\download\git\libs\qt5\qtbase\src\plugins\sqldrivers>D:\CraftRoot\build\libs\qt5\qtbase\qt5-dev\bin\qmake.exe -- MYSQL_INCDIR=D:/CraftRoot/download/mysql-8.0.17-winx64/include "MYSQL_LIBDIR=D:/CraftRoot/download/mysql-8.0.17-win
              x64/lib"
              
              Running configuration tests...
              Checking for DB2 (IBM)... no
              Checking for InterBase... no
              Checking for MySQL... yes
              Checking for OCI (Oracle)... no
              Checking for ODBC... yes
              Checking for PostgreSQL... no
              Checking for SQLite (version 2)... no
              Checking for TDS (Sybase)... no
              Done running configuration tests.
              
              Configure summary:
              
              Qt Sql Drivers:
                DB2 (IBM) .............................. no
                InterBase .............................. no
                MySql .................................. yes
                OCI (Oracle) ........................... no
                ODBC ................................... yes
                PostgreSQL ............................. no
                SQLite2 ................................ no
                SQLite ................................. yes
                  Using system provided SQLite ......... no
                TDS (Sybase) ........................... no
              
              Qt is now configured for building. Just run 'nmake'.
              Once everything is built, Qt is installed.
              You should NOT run 'nmake install'.
              Note that this build cannot be deployed to other machines or devices.
              
              Prior to reconfiguration, make sure you remove any leftovers from the previous build.
              
              J Offline
              J Offline
              James Hankins
              wrote on last edited by
              #6

              Thank you. I tried this just now but I seem to not be getting the Qt Sql Drivers summary showing mysql afterwards:

              D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>del config.cache
              
              D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>qmake -- MYSQL_INCDIR=D:/Users/jhankins/Documents/mysql-8.0.17-winx64/mysql-8.0.17-winx64/include "MYSQL_LIBDIR=D:/Users/jhankins/Documents/mysql-8.0.17-winx64/mysql-8.0.17-winx64/lib"
              
              Running configuration tests...
              Checking for DB2 (IBM)... no
              Checking for InterBase... no
              Checking for MySQL... no
              Checking for OCI (Oracle)... no
              Checking for ODBC... yes
              Checking for PostgreSQL... no
              Checking for SQLite (version 2)... no
              Checking for TDS (Sybase)... no
              Done running configuration tests.
              
              Configure summary:
              
              Qt Sql Drivers:
                DB2 (IBM) .............................. no
                InterBase .............................. no
                MySql .................................. no
                OCI (Oracle) ........................... no
                ODBC ................................... yes
                PostgreSQL ............................. no
                SQLite2 ................................ no
                SQLite ................................. yes
                  Using system provided SQLite ......... no
                TDS (Sybase) ........................... no
              
              Qt is now configured for building. Just run 'nmake'.
              Once everything is built, you must run 'nmake install'.
              Qt will be installed into 'D:\Users\jhankins\Qt\5.13.1\msvc2017_64'.
              
              Prior to reconfiguration, make sure you remove any leftovers from
              the previous build.
              
              
              D:\Users\jhankins\Qt\5.13.1\Src\qtbase\src\plugins\sqldrivers>
              
              1 Reply Last reply
              0
              • Christian EhrlicherC Offline
                Christian EhrlicherC Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You quoted MYSQL_LIBDIR - this is wrong. There is also a config.log where you can take a look what's going wrong.

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                J 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  You quoted MYSQL_LIBDIR - this is wrong. There is also a config.log where you can take a look what's going wrong.

                  J Offline
                  J Offline
                  James Hankins
                  wrote on last edited by
                  #8

                  @christian-ehrlicher config.log for the win! Thank you! So the issue was the VS prompt I used was apparently set to x86. Used the VS x64 Native prompt and qmake showed the mysql Yes and subsequently the nmake sub-mysql worked . Thank you very much!

                  1 Reply Last reply
                  1
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Nice. Then please mark the topic as solved :)

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      James Hankins
                      wrote on last edited by
                      #10

                      As a follow up on this: I did get the successful build of the plugin and ran nmake install which drops the artifacts into the D:\Users\jhankins\Qt\5.13.1\msvc2017_64\plugins\sqldrivers\ folder. I see them there.

                      Do I need to do anything else in the .PRO file to enable other than QT += sql ?

                      As when I attempt to connect I'm still getting:

                      QSqlDatabase: QMYSQL driver not loaded
                      QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                      

                      My project is set to Desktop Qt 5.13.1 MSVC2017 64bit.

                      Is there some kind of extra step to point the use of libmysql.dll to this plugin like I had to do for MacOS?

                      I didn't have to add a unix libs += on my test macOS project. Not real clear how the plugins libs get incorporated into the project.

                      1 Reply Last reply
                      0
                      • Christian EhrlicherC Offline
                        Christian EhrlicherC Offline
                        Christian Ehrlicher
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        You have to make sure that the mysql libraries are found (= are in the same folder as the plugin or in PATH) which doesn't seem to be the case here.

                        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                        Visit the Qt Academy at https://academy.qt.io/catalog

                        1 Reply Last reply
                        2
                        • J Offline
                          J Offline
                          James Hankins
                          wrote on last edited by
                          #12

                          I added libmysql.dll into the plugin directory and that seems to have done it. I first tried adding the lib directory into the path but this didn't seem to work.

                          Thanks a million. I have been fighting this bugger for too long.

                          N 1 Reply Last reply
                          0
                          • J James Hankins

                            I added libmysql.dll into the plugin directory and that seems to have done it. I first tried adding the lib directory into the path but this didn't seem to work.

                            Thanks a million. I have been fighting this bugger for too long.

                            N Offline
                            N Offline
                            nn26
                            wrote on last edited by nn26
                            #13

                            @SGaist @Christian-Ehrlicher @James-Hankins I am getting same error. can you tell me where exacly have you added libmysql.dll file? which plugin directory?

                            QSqlDatabase: QMYSQL driver not loaded
                            QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                            ERROR: Adding database failed!
                            
                            1 Reply Last reply
                            0
                            • Christian EhrlicherC Offline
                              Christian EhrlicherC Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on last edited by Christian Ehrlicher
                              #14

                              @nn26 said in What is current (2019) recommended process (complete) for building a MySQL Driver for use with Qt on Windows?:

                              exacly have you added libmysql.dll file? which plugin directory?

                              Since it's a sql plugin I would try to sqldrivers subdir. Or use windeployqt.

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              1 Reply Last reply
                              2

                              • Login

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