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. Getting QSqlError "Driver not loaded"
Qt 6.11 is out! See what's new in the release blog

Getting QSqlError "Driver not loaded"

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 308 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.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote last edited by
    #2

    You have to build the Qt sql driver for MySQL by yourself for legal reasons as described here: https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

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

    D 1 Reply Last reply
    3
    • Christian EhrlicherC Christian Ehrlicher

      You have to build the Qt sql driver for MySQL by yourself for legal reasons as described here: https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

      D Offline
      D Offline
      DiBosco
      wrote last edited by
      #3

      @Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":

      You have to build the Qt sql driver for MySQL by yourself for legal reasons as described here: https://doc.qt.io/qt-6/sql-driver.html#how-to-build-the-qmysql-plugin-on-windows

      I did see that and I'd [mis]understood it as saying DLLs were now being supplied.

      So, looking at this bit of info:

      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_ROOT="C:\mysql-8.0.22-winx64"
      cmake --build .
      cmake --install .
      

      I have some questions about that.

      These two lines:

      mkdir build-sqldrivers
      cd build-sqldrivers
      

      What directory are these new subdirectories to be put? Or does it not matter?

      qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_ROOT="C:\mysql-8.0.22-winx64"
      

      This <qt_installation_path> I am assuming is where that particular release of Qt lives. So in my case this is

      c:\Qt6\6.10.2

      However, that does not have a source directory. So, do I have to download the Qt source here first?

      qt_installation_path>\<platform>
      
      

      What is platform here?

      DMySQL_ROOT="C:\mysql-8.0.22-winx64
      

      Is this, for me:

      C:\Program Files\MariaDB\MariaDB Connector C 64-bit

      Where I have subdirectories:

      lib which has mariadb.dll

      And:

      include which has mysql.h

      And at the end of this, what will it actually create in terms of a DLL? Something like QMAriadb.dll or QMysql.dll and it's basically jiust a wrapper for the already supplied mariadb.dll?

      Thanks.

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

        Hi,

        You can put the build wherever you want outside of Qt's sources.

        The <qt_installation_path> is the root where you have Qt. In your case it seems to be C:/Qt6.

        You have to download the Qt sources that matches the version you want to build the driver for. You can do that through the Maintenance Tool.

        platform is what you have after C:/Qt6/6.10.2

        It will create a plugin that will use the library you supplied.

        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
        2
        • D Offline
          D Offline
          DiBosco
          wrote last edited by DiBosco
          #5

          OK, thanks to everyone, I now have it compiled and running. It fought me. A lot.

          I had to install cmake, then ninja, then reboot. Then eventually worked out that I was trying to use Mingw parts with MSVC compiler, so rebuilt against Qt using Mingw as the compiler and it eventually worked.

          Uff, it's always easier on Linux! :D

          Why do you have to compile on Windows when on Linux this just works? None of this having to build libraries stuff!

          Christian EhrlicherC 1 Reply Last reply
          0
          • D DiBosco

            OK, thanks to everyone, I now have it compiled and running. It fought me. A lot.

            I had to install cmake, then ninja, then reboot. Then eventually worked out that I was trying to use Mingw parts with MSVC compiler, so rebuilt against Qt using Mingw as the compiler and it eventually worked.

            Uff, it's always easier on Linux! :D

            Why do you have to compile on Windows when on Linux this just works? None of this having to build libraries stuff!

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote last edited by Christian Ehrlicher
            #6

            @DiBosco said in Getting QSqlError "Driver not loaded":

            Why do you have to compile on Windows when on Linux this just works?

            You have to build the Qt sql driver for MySQL by yourself for legal reasons

            And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.

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

            D 1 Reply Last reply
            0
            • Joe von HabsburgJ Offline
              Joe von HabsburgJ Offline
              Joe von Habsburg
              wrote last edited by
              #7

              I use for PostgreSQL, maybe help you

              set(POSTGRESQL_DLL_DIR "C:/Program Files/PostgreSQL/17/bin")
              foreach(dll IN ITEMS
                  libpq.dll
                  libssl-3-x64.dll
                  libcrypto-3-x64.dll
                  libiconv-2.dll
                  libintl-9.dll
                  libpgtypes.dll
                  libwinpthread-1.dll
                  libxml2.dll
                  libxslt.dll
                  libzstd.dll
                  libcurl.dll
                  libecpg.dll
                  libecpg_compat.dll
                  liblz4.dll
              )
                  add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
                      COMMAND ${CMAKE_COMMAND} -E copy_if_different
                          "${POSTGRESQL_DLL_DIR}/${dll}"
                          $<TARGET_FILE_DIR:${PROJECT_NAME}>
                  )
              endforeach()
              
              1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @DiBosco said in Getting QSqlError "Driver not loaded":

                Why do you have to compile on Windows when on Linux this just works?

                You have to build the Qt sql driver for MySQL by yourself for legal reasons

                And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.

                D Offline
                D Offline
                DiBosco
                wrote last edited by DiBosco
                #8

                @Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":

                @DiBosco said in Getting QSqlError "Driver not loaded":

                Why do you have to compile on Windows when on Linux this just works?

                You have to build the Qt sql driver for MySQL by yourself for legal reasons

                And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.

                I'm not clear what you're saying here, Christian. I didn't compile the whole of Qt, just the mariadb libs. Or are you saying that what SGaist said wasn't quite right and there are binaries available? ie I did not have to compile mariadb libraries for Qt?

                SGaistS Christian EhrlicherC 2 Replies Last reply
                0
                • D DiBosco

                  @Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":

                  @DiBosco said in Getting QSqlError "Driver not loaded":

                  Why do you have to compile on Windows when on Linux this just works?

                  You have to build the Qt sql driver for MySQL by yourself for legal reasons

                  And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.

                  I'm not clear what you're saying here, Christian. I didn't compile the whole of Qt, just the mariadb libs. Or are you saying that what SGaist said wasn't quite right and there are binaries available? ie I did not have to compile mariadb libraries for Qt?

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote last edited by
                  #9

                  @DiBosco I think it's likely just a miscomprehension.

                  We had many people trying to build the whole of Qt in place of just building the plugins they needed following the documentation.

                  From the looks of it, you followed the right path but just had an issue with the compiler setup.

                  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
                  2
                  • D DiBosco

                    @Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":

                    @DiBosco said in Getting QSqlError "Driver not loaded":

                    Why do you have to compile on Windows when on Linux this just works?

                    You have to build the Qt sql driver for MySQL by yourself for legal reasons

                    And there is no need to compile Qt by yourself. Mingw and msvc binaries are provided by the installer and the MySQL plugin compiles with both.

                    I'm not clear what you're saying here, Christian. I didn't compile the whole of Qt, just the mariadb libs. Or are you saying that what SGaist said wasn't quite right and there are binaries available? ie I did not have to compile mariadb libraries for Qt?

                    Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote last edited by
                    #10

                    @DiBosco said in Getting QSqlError "Driver not loaded":

                    just the mariadb libs.

                    Even this is not needed - you only need to compile the Qt sql plugin. The rest is already available as binary.

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

                    D 1 Reply Last reply
                    0
                    • Christian EhrlicherC Christian Ehrlicher

                      @DiBosco said in Getting QSqlError "Driver not loaded":

                      just the mariadb libs.

                      Even this is not needed - you only need to compile the Qt sql plugin. The rest is already available as binary.

                      D Offline
                      D Offline
                      DiBosco
                      wrote last edited by
                      #11

                      @Christian-Ehrlicher said in Getting QSqlError "Driver not loaded":

                      @DiBosco said in Getting QSqlError "Driver not loaded":

                      just the mariadb libs.

                      Even this is not needed - you only need to compile the Qt sql plugin. The rest is already available as binary.

                      Yep, that's all I did. Sounds like I described it poorly.

                      Am still intruiged as to why this has to be done on Windows, but not on Linux (or at least my Linux distro).

                      1 Reply Last reply
                      0
                      • D DiBosco has marked this topic as solved

                      • Login

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