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. QMYSQL DRIVER NOT LOADED
Qt 6.11 is out! See what's new in the release blog

QMYSQL DRIVER NOT LOADED

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 4 Posters 1.8k 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.
  • N Offline
    N Offline
    nguyendinh
    wrote on last edited by
    #1

    Hi All,

    I'm trying to make a program that inserts a record into a database. I have lost 2 days for error.I can't connect to the database. i get the following error:
    QSqlDatabase: QMYSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL3 QODBC !
    I understand I have to buid mysql driver with mysql.h and ilbmysql.dll supply by MYSQL

    I'm trying with MinGW 7.3.0 32 bit command:
    cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers
    qmake -- MYSQL_INCDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/include" MYSQL_LIBDIR="C:/Program Files/MySQL/MySQL Connector C 6.1/lib"
    this error:
    qt1.PNG

    and other:
    cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
    qmake "INCLUDEPATH+=C:\Program Files (x86)\MySQL\MySQL Server 5.5\include" "LIBS+=C:\Program Files (x86)\MySQL\MySQL Server 5.5\lib\libmysql.lib" mysql.pro

    this error:
    qt2.PNG

    I read the Error on github and then I config I delete QMAKE_USE+= mysql in mysql.pro
    qt3.PNG

    And ther command:
    qt4.PNG

    I can't build file qsqlmysql.dll for driver !! Please help me . If you buid driver for QT 5.14.1 sucsses , can you send me qsqlmysql.dll file ! Thanks best for your time !!!!

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

      Hi and welcome to devnet,

      You are missing a double quote in the LIBS part of your qmake call.

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

      N 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi and welcome to devnet,

        You are missing a double quote in the LIBS part of your qmake call.

        N Offline
        N Offline
        nguyendinh
        wrote on last edited by
        #3

        @SGaist said in QMYSQL DRIVER NOT LOADED:

        Hi and welcome to devnet,
        You are missing a double quote in the LIBS part of your qmake call.

        Thanks for reply I see you solved this problem in other topic but What i was wrong :((
        qt5.PNG

        jsulmJ 1 Reply Last reply
        0
        • N nguyendinh

          @SGaist said in QMYSQL DRIVER NOT LOADED:

          Hi and welcome to devnet,
          You are missing a double quote in the LIBS part of your qmake call.

          Thanks for reply I see you solved this problem in other topic but What i was wrong :((
          qt5.PNG

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @nguyendinh said in QMYSQL DRIVER NOT LOADED:

          What i was wrong

          It would be nice if you would put text instead of screen-shots!
          What you are doing wrong: you need to put paths containing spaces into "". If you take time to take a closer look at your screen- shot you will see what is wrong: the path to include directory contains spaces, but you did not put it into "", so you have stuff like:

          -IC:\Program -IFiles
          

          which is of course wrong.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • N Offline
            N Offline
            nguyendinh
            wrote on last edited by nguyendinh
            #5

            @jsulm
            Thanks for your support
            This my command in QT 5.14.1 mingW 7.3.0 32bit
            (I use MYSQL 8.0 64 bit)

            This my command:
            1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
            2.qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro

            And then this equal:
            q1.PNG

            jsulmJ 1 Reply Last reply
            0
            • N nguyendinh

              @jsulm
              Thanks for your support
              This my command in QT 5.14.1 mingW 7.3.0 32bit
              (I use MYSQL 8.0 64 bit)

              This my command:
              1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
              2.qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro

              And then this equal:
              q1.PNG

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @nguyendinh said in QMYSQL DRIVER NOT LOADED:

              qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro

              qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              N 2 Replies Last reply
              0
              • jsulmJ jsulm

                @nguyendinh said in QMYSQL DRIVER NOT LOADED:

                qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro

                qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro
                
                N Offline
                N Offline
                nguyendinh
                wrote on last edited by nguyendinh
                #7

                @jsulm Thanks you but the same as
                1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
                2.qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro
                3.mingw32-make

                q2.PNG

                jsulmJ 1 Reply Last reply
                0
                • N nguyendinh

                  @jsulm Thanks you but the same as
                  1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
                  2.qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro
                  3.mingw32-make

                  q2.PNG

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @nguyendinh Your screen-shot still shows your wrong qmake call...
                  Please do it like I suggested.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  N 1 Reply Last reply
                  1
                  • jsulmJ jsulm

                    @nguyendinh Your screen-shot still shows your wrong qmake call...
                    Please do it like I suggested.

                    N Offline
                    N Offline
                    nguyendinh
                    wrote on last edited by
                    #9

                    @jsulm sorry I upload wrong images
                    i copied your command but the equal same as:
                    1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
                    2.qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib"mysql.pro
                    3.mingw32-make

                    Thanks best for your time!!!
                    q4.PNG

                    jsulmJ 1 Reply Last reply
                    0
                    • N nguyendinh

                      @jsulm sorry I upload wrong images
                      i copied your command but the equal same as:
                      1.cd C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\mysql
                      2.qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib"mysql.pro
                      3.mingw32-make

                      Thanks best for your time!!!
                      q4.PNG

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @nguyendinh Please make sure you call qmake/make from a clean state. Means: remove all build artefacts first. Better do out of source build (not from source code directory).

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @nguyendinh said in QMYSQL DRIVER NOT LOADED:

                        qmake "INCLUDEPATH+=C:\Program Files\MySQL\MySQL Server 8.0\include" "LIBS+=C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro

                        qmake INCLUDEPATH+="C:\Program Files\MySQL\MySQL Server 8.0\include" LIBS+="C:\Program Files\MySQL\MySQL Server 8.0\lib\libmysql.lib" mysql.pro
                        
                        N Offline
                        N Offline
                        nguyendinh
                        wrote on last edited by
                        #11

                        @jsulm Thanks every body In this day , I solved the problem. All problem in Makefile
                        Makefile buid qsqlmysql.dll driver but the linked LIBS or INCLUDEPATH wrong because you using more than 1 qmake command . And this solved you put the true link in Makefile
                        (Makefile in C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers)
                        q1.PNG

                        You can fix Makefile in with notepad or etc and then save file
                        then again in QT command run: mingw32-make

                        and then qsqlmysql build in C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\plugins\sqldrivers
                        then you have to coppy this file for C:\Qt\Qt5.14.1\5.14.1\mingw73_32\plugins\sqldrivers

                        Now we can connect to mysql workbench Thanks for all.

                        lincolnL 1 Reply Last reply
                        0
                        • N nguyendinh

                          @jsulm Thanks every body In this day , I solved the problem. All problem in Makefile
                          Makefile buid qsqlmysql.dll driver but the linked LIBS or INCLUDEPATH wrong because you using more than 1 qmake command . And this solved you put the true link in Makefile
                          (Makefile in C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers)
                          q1.PNG

                          You can fix Makefile in with notepad or etc and then save file
                          then again in QT command run: mingw32-make

                          and then qsqlmysql build in C:\Qt\Qt5.14.1\5.14.1\Src\qtbase\src\plugins\sqldrivers\plugins\sqldrivers
                          then you have to coppy this file for C:\Qt\Qt5.14.1\5.14.1\mingw73_32\plugins\sqldrivers

                          Now we can connect to mysql workbench Thanks for all.

                          lincolnL Offline
                          lincolnL Offline
                          lincoln
                          wrote on last edited by
                          #12

                          @nguyendinh link text

                          Solitary wolf

                          N 1 Reply Last reply
                          0
                          • lincolnL lincoln

                            @nguyendinh link text

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

                            @lincoln Capture.PNG

                            Open Makefile with notepad or IDE C++ , config and then save file.

                            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