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 and Library mysql is not defined

QMYSQL driver not loaded and Library mysql is not defined

Scheduled Pinned Locked Moved Solved General and Desktop
qmakeqmysqldriver not loadunknown qmake
44 Posts 6 Posters 9.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 jsulm
    28 Jun 2021, 13:32

    @Markyo Make sure you start from clean state without any build artefacts from previous tries. In case you're doing out-of-source builds delete and create the build folder. Else checkout the source code again.

    M Offline
    M Offline
    Markyo
    wrote on 28 Jun 2021, 13:54 last edited by
    #31

    @jsulm I deleted the config.cache file, but still get the same result. I don't know how to check if I'm doing out-of-source builds, and what is the build folder.

    J 1 Reply Last reply 28 Jun 2021, 13:56
    0
    • M Markyo
      28 Jun 2021, 13:54

      @jsulm I deleted the config.cache file, but still get the same result. I don't know how to check if I'm doing out-of-source builds, and what is the build folder.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 28 Jun 2021, 13:56 last edited by
      #32

      @Markyo said in QMYSQL driver not loaded and Library mysql is not defined:

      what is the build folder

      The folder in which you are when you call cmake.
      Out of source build means that the build folder is outside of the source folder.

      M 1 Reply Last reply 28 Jun 2021, 14:05
      0
      • J jsulm
        28 Jun 2021, 13:56

        @Markyo said in QMYSQL driver not loaded and Library mysql is not defined:

        what is the build folder

        The folder in which you are when you call cmake.
        Out of source build means that the build folder is outside of the source folder.

        M Offline
        M Offline
        Markyo
        wrote on 28 Jun 2021, 14:05 last edited by
        #33

        @jsulm I'm building in this folder:

        C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers
        

        I'm not sure I have to delete this folder

        J 1 Reply Last reply 28 Jun 2021, 14:07
        0
        • M Markyo
          28 Jun 2021, 14:05

          @jsulm I'm building in this folder:

          C:\Qt\5.12.5\Src\qtbase\src\plugins\sqldrivers
          

          I'm not sure I have to delete this folder

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 28 Jun 2021, 14:07 last edited by
          #34

          @Markyo Well, since you're not doing out of source build you should not delete it. Instead delete all build artefacts (files created during your build attempts) manually.

          M 1 Reply Last reply 28 Jun 2021, 14:21
          0
          • J jsulm
            28 Jun 2021, 14:07

            @Markyo Well, since you're not doing out of source build you should not delete it. Instead delete all build artefacts (files created during your build attempts) manually.

            M Offline
            M Offline
            Markyo
            wrote on 28 Jun 2021, 14:21 last edited by
            #35

            @jsulm are there files other than config.cache?

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mickleholts
              Banned
              wrote on 28 Jun 2021, 18:04 last edited by Mickleholts
              #36
              This post is deleted!
              S 1 Reply Last reply 28 Jun 2021, 18:07
              0
              • M Mickleholts
                28 Jun 2021, 18:04

                This post is deleted!

                S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 28 Jun 2021, 18:07 last edited by
                #37

                @Mickleholts hi,

                @jsulm already fave quite a lot of advices. Did you follow them ?

                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
                • M Offline
                  M Offline
                  Markyo
                  wrote on 2 Jul 2021, 10:08 last edited by
                  #38

                  Hello, I'm coming back here again to look for some solutions !
                  Due to difference of version, I reinstalled another version, several times, and for my last try, with this command:

                  C:\Qt\5.12.5\msvc2017\bin\qmake.exe -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\lib"
                  

                  I get this environment problem:

                  Project ERROR: Cannot run compiler 'cl'. Output:
                  ===================
                  ===================
                  Maybe you forgot to setup the environment?
                  

                  Honestly, I don't understand why it is so hard to use the MySQL driver..

                  J 1 Reply Last reply 2 Jul 2021, 10:14
                  0
                  • C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 2 Jul 2021, 10:12 last edited by
                    #39

                    @Markyo said in QMYSQL driver not loaded and Library mysql is not defined:

                    Maybe you forgot to setup the environment?

                    You did not set up the MSVC environment as the error tells you - you have to run it from a MSVC command prompt. Nothing Qt specific - if you want to use a compiler in an environment you have to properly set it up.

                    Honestly, I don't understand why it is so hard to use the MySQL driver..

                    Ask Oracle why they changed their license so it can be shipped as pre-build library

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

                    M 1 Reply Last reply 2 Jul 2021, 13:01
                    1
                    • M Markyo
                      2 Jul 2021, 10:08

                      Hello, I'm coming back here again to look for some solutions !
                      Due to difference of version, I reinstalled another version, several times, and for my last try, with this command:

                      C:\Qt\5.12.5\msvc2017\bin\qmake.exe -- MYSQL_INCDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\include" MYSQL_LIBDIR="C:\Program Files\MySQL\MySQL Connector C 6.1\lib"
                      

                      I get this environment problem:

                      Project ERROR: Cannot run compiler 'cl'. Output:
                      ===================
                      ===================
                      Maybe you forgot to setup the environment?
                      

                      Honestly, I don't understand why it is so hard to use the MySQL driver..

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 2 Jul 2021, 10:14 last edited by
                      #40
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • C Christian Ehrlicher
                        2 Jul 2021, 10:12

                        @Markyo said in QMYSQL driver not loaded and Library mysql is not defined:

                        Maybe you forgot to setup the environment?

                        You did not set up the MSVC environment as the error tells you - you have to run it from a MSVC command prompt. Nothing Qt specific - if you want to use a compiler in an environment you have to properly set it up.

                        Honestly, I don't understand why it is so hard to use the MySQL driver..

                        Ask Oracle why they changed their license so it can be shipped as pre-build library

                        M Offline
                        M Offline
                        Markyo
                        wrote on 2 Jul 2021, 13:01 last edited by
                        #41

                        @Christian-Ehrlicher thx so much it worked, the command tell me this:

                        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, you must run 'nmake install'.
                        Qt will be installed into 'C:\Qt\5.12.5\msvc2017'.
                        
                        Prior to reconfiguration, make sure you remove any leftovers from
                        the previous build.
                        

                        So, MySQL is available, I typed nmake, then nmake install, then nmake install in mysql directory, everything seems to work.

                        I rebuilt my app, and ran the app and get this:

                        QML debugging is enabled. Only use this in a safe environment.
                        QSqlDatabase: QMYSQL driver not loaded
                        QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                        

                        Don't understand why it is available but not loaded.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 2 Jul 2021, 13:06 last edited by
                          #42

                          The driver needs the dlls to be loaded.

                          You can help finding them modifying the PATH environment variable in the Run part of the Project panel in Qt Creator.

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

                          M 2 Replies Last reply 2 Jul 2021, 14:30
                          0
                          • S SGaist
                            2 Jul 2021, 13:06

                            The driver needs the dlls to be loaded.

                            You can help finding them modifying the PATH environment variable in the Run part of the Project panel in Qt Creator.

                            M Offline
                            M Offline
                            Markyo
                            wrote on 2 Jul 2021, 14:30 last edited by
                            #43

                            @SGaist After editing PATH variable to add dll's path, it finally worked !

                            Thank you so much everyone for your time and helpful responses !

                            1 Reply Last reply
                            0
                            • S SGaist
                              2 Jul 2021, 13:06

                              The driver needs the dlls to be loaded.

                              You can help finding them modifying the PATH environment variable in the Run part of the Project panel in Qt Creator.

                              M Offline
                              M Offline
                              Markyo
                              wrote on 7 Jul 2021, 14:41 last edited by Markyo 7 Jul 2021, 14:46
                              #44

                              @SGaist Hello! I'm building a second app using QMySQL database, the first app (the one about this topic) works perfectly as expected, but the second tells me that the driver isn't loaded.

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

                              I added mysql dll dir in PATH environment variable, but same problem stay the same..

                              Have you an idea please?

                              EDIT: nevermind, I'm just stupid, I forgot the "Q" before "MYSQL" call in code line:

                              QSqlDatabase db = QSqlDatabase::addDatabase("MYSQL");
                              

                              Now it's:

                              QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
                              

                              and strangely, works better..

                              Again, thank you all for your help!

                              1 Reply Last reply
                              0

                              40/44

                              2 Jul 2021, 10:14

                              • Login

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