Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. Building QMYSQL / MARIADB with Qt 6.3.0
Forum Update on Monday, May 27th 2025

Building QMYSQL / MARIADB with Qt 6.3.0

Scheduled Pinned Locked Moved Unsolved Qt 6
qmysqlmariadb3.6.0
13 Posts 2 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.
  • A Offline
    A Offline
    AnUnusualRemote
    wrote on last edited by
    #1

    Hi all, been having a nightmare with trying to build QMYSQL/MariaDB drivers for Qt6. I read through the documentation (https://doc.qt.io/qt-6/sql-driver.html#qmysql) and found all the required files within my installation of the MariaDB connecter, relative to my Qt version (running 64bit).
    Afterwards, I followed the instructions and assumed that I was to build the plugin in the directory of my Qt 6.3.0 bin folders (for mingw_64 or msvc2019), which left me with an error.

    '"cmake"' is not recognized as an internal or external command, operable program or batch file.
    

    I assumed that Qt 6.3.0 didn't come with Qt-cmake for whatever reason, so I opted to install WSL and try and download the QMYSQL drivers via package at https://ubuntu.pkgs.org/22.04/ubuntu-universe-amd64/libqt6sql6-mysql_6.2.4+dfsg-2ubuntu1_amd64.deb.html instead as a work-around.
    This worked, but I have no clue where the plugin is now located on my windows machine and where to place it, even if I did manage to find where they had been placed.

    Is there any possible way I could acquire the qt-cmake.exe as it hasn't come with the version? Or does 6.3.0 not support this plugin yet?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AnUnusualRemote
      wrote on last edited by
      #2

      Something I didn't realise, when looking at Qt Creator, I was using a Replacement for Qt 6.2.3. This, along with receiving .dll files from a friend managed to output

      QSqlDatabase: QMYSQL driver not loaded
      QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
      

      When running my program using QMYSQL. Code below is how I'm designating QMYSQL as the driver used.

        QSqlDatabase database = QSqlDatabase::addDatabase("QMYSQL");
          database.setHostName("localhost");
          database.setDatabaseName("database_name");
          database.setUserName("username");
          database.setPassword("password");
      

      So this means that either something is wrong with how I'm trying to load the QMYSQL driver, or there's something beyond this that could be preventing the driver from being loaded. Any ideas on what this could be?

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

        Hi and welcome to devnet,

        If memory serves well, the online installer also provides the option to install cmake.

        As for the loading issue, start your application with the QT_DEBUG_PLUGINS environment variable set to 1. You can do that in the Run part of the Project panel.

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

        A 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi and welcome to devnet,

          If memory serves well, the online installer also provides the option to install cmake.

          As for the loading issue, start your application with the QT_DEBUG_PLUGINS environment variable set to 1. You can do that in the Run part of the Project panel.

          A Offline
          A Offline
          AnUnusualRemote
          wrote on last edited by AnUnusualRemote
          #4

          Sorry, I have done that correct, I just found it.
          That doesn't seem to have done anything, in fact it was already set towards 1 when I checked. The online installer also seems to have CMake 3.21.1 64-bit showing as installed under Developer and Designer Tools.

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

            If the environment variable is properly defined, you should have a dump of information about the plugins being loaded and why they failed.

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

            A 1 Reply Last reply
            0
            • SGaistS SGaist

              If the environment variable is properly defined, you should have a dump of information about the plugins being loaded and why they failed.

              A Offline
              A Offline
              AnUnusualRemote
              wrote on last edited by
              #6

              @SGaist
              I'm assuming this would be

              {
                  "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                  "MetaData": {
                      "Keys": [
                          "QMYSQL",
                          "QMARIADB"
                      ]
                  },
                  "archlevel": 0,
                  "className": "QMYSQLDriverPlugin",
                  "debug": true,
                  "version": 393728
              }
              
              
              qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
              qt.core.plugin.factoryloader: looking at "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlodbc.dll"
              qt.core.plugin.loader: Found metadata in lib C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlodbc.dll, metadata=
              

              Along with this line.

              qt.core.library: "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlmysql.dll" cannot load: Cannot load library C:\Qt\6.3.0\mingw_64\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found.
              qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "C:/Qt/6.3.0/mingw_64/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\\Qt\\6.3.0\\mingw_64\\plugins\\sqldrivers\\qsqlmysql.dll: The specified module could not be found."
              

              sqldriver folder containing .dll files
              Since that's the sqldriver folder, I checked. Results are above. I can only guess that there's a missing .debug file, or that the .dll is incompatible with Qt for some reason.

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

                Maybe a silly question but are you sure that the dll you have now is from the correct compiler ?

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

                A 1 Reply Last reply
                0
                • SGaistS SGaist

                  Maybe a silly question but are you sure that the dll you have now is from the correct compiler ?

                  A Offline
                  A Offline
                  AnUnusualRemote
                  wrote on last edited by
                  #8

                  @SGaist
                  Very likely that it may not be from the right compiler, I could not compile it, so I asked a friend to instead. I suppose my best option right now is to try and build everything myself.

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

                    You do not have to rebuild everything. Just the plugin.

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

                    A 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      You do not have to rebuild everything. Just the plugin.

                      A Offline
                      A Offline
                      AnUnusualRemote
                      wrote on last edited by
                      #10

                      @SGaist
                      I'm not entirely sure how to build it based on the documentation. I have the files for MariaDB location in the right folders when it comes to the .lib, .dll and .h files. Problem is that I'm not sure where I should be for building the plugins when it comes to the command prompt.

                      mkdir build-sqldrivers
                      cd build-sqldrivers
                      
                      qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
                      cmake --build .
                      cmake --install .
                      

                      I'm not entirely sure where I should be located within my file structure to build the plugins, inside of the Qt 6.3.0 folder? The bin folder of the Qt 6.3.0 folder perhaps? qt-cmake doesn't seem to be recgonised as a command, so I assume it's located somewhere inside of the Qt folder.

                      'qt-cmake' is not recognized as an internal or external command, operable program or batch file.
                      

                      I also do not know what Ninja refers to within the command. Do I need to install this too?

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

                        Try with just cmake in place of qt-cmake.

                        As for Ninja, it's also available through the installer.

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

                        A 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          Try with just cmake in place of qt-cmake.

                          As for Ninja, it's also available through the installer.

                          A Offline
                          A Offline
                          AnUnusualRemote
                          wrote on last edited by
                          #12

                          @SGaist
                          Since I'm using and building for MariaDB

                          qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib"
                          

                          The DMySQL and DMySQL_LIBRARY should probably be replaced with DMariaDB or some equivalent, correct? The locations will change, but obviously those are where I've installed the relevant files.

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

                            From memory, no, MariaDB is a drop in replacement so it would not make sense to complicate the build system for that.

                            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