Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QMYSQL driver build problem
Qt 6.12 LTS is out! See what's new in the release blog

QMYSQL driver build problem

Scheduled Pinned Locked Moved Solved Installation and Deployment
13 Posts 7 Posters 1.8k Views 3 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.
  • L Offline
    L Offline
    lorenko
    wrote on last edited by
    #2

    Ops sorry solved removing config.cache

    sorry

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lorenko
      wrote on last edited by
      #3

      Ehm.....
      but still QSqlDatabase: QMYSQL driver not loaded

      mysql in /usr/local

      using otool
      otool -L libqsqlmysql.dylib

      libqsqlmysql.dylib:
      libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
      @rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.14.0, current version 5.14.2)
      @rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.14.0, current version 5.14.2)
      /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
      /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
      @rpath/libmysqlclient.21.dylib (compatibility version 21.0.0, current version 21.0.0)
      /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 800.6.0)
      /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)

      thanks

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

        Start your application with the QT_DEBUG_PLUGINS environment variable set to 1.

        That will give you more information about what is going on.

        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
        1
        • L lorenko

          Re: Trouble building the QMYSQL Plugin on Unix (Mint 19.2)

          I have the same problem with MacOs X (Catalina) :

          sqldrivers % /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake -- MYSQL_PREFIX=/usr/local

          Running configuration tests...
          Done running configuration tests.

          Configure summary:

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

          Tried /usr/local/mysql
          but same

          log file :

          (only mysql part)
          loaded result for library config.sqldrivers.libraries.mysql
          Trying source 0 (type mysqlConfig) of library mysql ...
          mysql_config not found.
          => source produced no result.
          Trying source 1 (type mysqlConfig) of library mysql ...
          mysql_config not found.
          => source produced no result.
          Trying source 2 (type mysqlConfig) of library mysql ...
          mysql_config not found.
          => source produced no result.
          Trying source 3 (type mysqlConfig) of library mysql ...
          mysql_config not found.
          => source produced no result.
          Trying source 4 (type inline) of library mysql ...
          mysql.h not found in [/usr/local/include] and global paths.
          => source produced no result.
          Trying source 5 (type inline) of library mysql ...
          => source failed condition 'config.win32'.
          Trying source 6 (type inline) of library mysql ...
          mysql.h not found in [/usr/local/include] and global paths.
          => source produced no result.
          test config.sqldrivers.libraries.mysql FAILED

          Thanks

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

          @lorenko https://forum.qt.io/topic/113712/qmysql-driver-not-loaded see my topic and all probelm in Make file open it with notepad or IDE C++ config the link INCLUDEPATH or LIBS I have lost 1 week this fuck problem

          you can using
          qmake INCLUDEPATH+="C:\PROGRA~2\MySQL\MYSQLS~1.5\include" LIBS+="C:\PROGRA~2\MySQL\MYSQLS~1.5\lib\libmysql.lib"mysql.pro

          or qmake -- MYSQL_INCDIR="C:\PROGRA~2\MySQL\MYSQLC~1.1\include" MYSQL_LIBDIR="C:\PROGRA~2\MySQL\MYSQLC~1.1\lib"

          but the linked you can see in Make-file is wrong because you using qmake more than 1 and Makefile buid linked wrong.

          jsulmJ 1 Reply Last reply
          0
          • N nguyendinh

            @lorenko https://forum.qt.io/topic/113712/qmysql-driver-not-loaded see my topic and all probelm in Make file open it with notepad or IDE C++ config the link INCLUDEPATH or LIBS I have lost 1 week this fuck problem

            you can using
            qmake INCLUDEPATH+="C:\PROGRA~2\MySQL\MYSQLS~1.5\include" LIBS+="C:\PROGRA~2\MySQL\MYSQLS~1.5\lib\libmysql.lib"mysql.pro

            or qmake -- MYSQL_INCDIR="C:\PROGRA~2\MySQL\MYSQLC~1.1\include" MYSQL_LIBDIR="C:\PROGRA~2\MySQL\MYSQLC~1.1\lib"

            but the linked you can see in Make-file is wrong because you using qmake more than 1 and Makefile buid linked wrong.

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

            @nguyendinh said in QMYSQL driver build problem:

            because you using qmake more than 1 and Makefile buid linked wrong

            Instead of editing makefiles make sure you start from a clean state: do out of source builds and delete content of the build directory before calling qmake again.

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

            1 Reply Last reply
            1
            • L Offline
              L Offline
              lorenko
              wrote on last edited by
              #7

              Thanks, but no way

              this my config log

              Command line: MYSQL_INCDIR=/usr/local/mysql-8.0.19-macos10.15-x86_64/include MYSQL_LIBDIR=/usr/local/mysql-8.0.19-macos10.15-x86_64/lib
              Global lib dirs: [] [/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib]
              Global inc dirs: [/usr/local/opt/openssl/include] [/Library/Developer/CommandLineTools/usr/include/c++/v1 /Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include /Library/Developer/CommandLineTools/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include]
              
              loaded result for library config.sqldrivers.libraries.mysql
              Trying source 0 (type mysqlConfig) of library mysql ...
              mysql_config not found.
                => source produced no result.
              Trying source 1 (type mysqlConfig) of library mysql ...
              mysql_config not found.
                => source produced no result.
              Trying source 2 (type mysqlConfig) of library mysql ...
              mysql_config not found.
                => source produced no result.
              Trying source 3 (type mysqlConfig) of library mysql ...
              mysql_config not found.
                => source produced no result.
              Trying source 4 (type inline) of library mysql ...
              + cd /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql && /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" 'INCLUDEPATH += /usr/local/opt/openssl/include' 'QMAKE_USE += mysql' 'QMAKE_LIBS_MYSQL = -L/usr/local/mysql-8.0.19-macos10.15-x86_64/lib -lmysqlclient_r' 'QMAKE_INCDIR_MYSQL = /usr/local/mysql-8.0.19-macos10.15-x86_64/include' /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql
              + cd /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql && MAKEFLAGS= make clean && MAKEFLAGS= make
              > rm -f main.o
              > rm -f *~ core *.core
              > /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -w -fPIC  -I. -I/usr/local/opt/openssl/include -I/usr/local/mysql-8.0.19-macos10.15-x86_64/include -I/Users/lorenko/Qt5.14.2/5.14.2/clang_64/mkspecs/macx-clang -o main.o main.cpp
              > /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -Wl,-rpath,@executable_path/../Frameworks -o mysql main.o   -L/usr/local/mysql-8.0.19-macos10.15-x86_64/lib -lmysqlclient_r   
              > ld: library not found for -lmysqlclient_r
              > clang: error: linker command failed with exit code 1 (use -v to see invocation)
              

              and qmake command

              /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake -- MYSQL_INCDIR="/usr/local/mysql-8.0.19-macos10.15-x86_64/include" MYSQL_LIBDIR="/usr/local/mysql-8.0.19-macos10.15-x86_64/lib"
              

              same results

              QSqlDatabase: QMYSQL driver not loaded
              QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
              
              kshegunovK 1 Reply Last reply
              0
              • L lorenko

                Thanks, but no way

                this my config log

                Command line: MYSQL_INCDIR=/usr/local/mysql-8.0.19-macos10.15-x86_64/include MYSQL_LIBDIR=/usr/local/mysql-8.0.19-macos10.15-x86_64/lib
                Global lib dirs: [] [/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib]
                Global inc dirs: [/usr/local/opt/openssl/include] [/Library/Developer/CommandLineTools/usr/include/c++/v1 /Library/Developer/CommandLineTools/usr/lib/clang/11.0.0/include /Library/Developer/CommandLineTools/usr/include /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include]
                
                loaded result for library config.sqldrivers.libraries.mysql
                Trying source 0 (type mysqlConfig) of library mysql ...
                mysql_config not found.
                  => source produced no result.
                Trying source 1 (type mysqlConfig) of library mysql ...
                mysql_config not found.
                  => source produced no result.
                Trying source 2 (type mysqlConfig) of library mysql ...
                mysql_config not found.
                  => source produced no result.
                Trying source 3 (type mysqlConfig) of library mysql ...
                mysql_config not found.
                  => source produced no result.
                Trying source 4 (type inline) of library mysql ...
                + cd /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql && /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += shared warn_off console single_arch" 'INCLUDEPATH += /usr/local/opt/openssl/include' 'QMAKE_USE += mysql' 'QMAKE_LIBS_MYSQL = -L/usr/local/mysql-8.0.19-macos10.15-x86_64/lib -lmysqlclient_r' 'QMAKE_INCDIR_MYSQL = /usr/local/mysql-8.0.19-macos10.15-x86_64/include' /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql
                + cd /Users/lorenko/Qt5.14.2/5.14.2/Src/qtbase/src/plugins/sqldrivers/config.tests/mysql && MAKEFLAGS= make clean && MAKEFLAGS= make
                > rm -f main.o
                > rm -f *~ core *.core
                > /Library/Developer/CommandLineTools/usr/bin/clang++ -c -pipe -stdlib=libc++ -O2 -std=gnu++11  -arch x86_64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -w -fPIC  -I. -I/usr/local/opt/openssl/include -I/usr/local/mysql-8.0.19-macos10.15-x86_64/include -I/Users/lorenko/Qt5.14.2/5.14.2/clang_64/mkspecs/macx-clang -o main.o main.cpp
                > /Library/Developer/CommandLineTools/usr/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch x86_64 -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.13 -Wl,-rpath,@executable_path/../Frameworks -o mysql main.o   -L/usr/local/mysql-8.0.19-macos10.15-x86_64/lib -lmysqlclient_r   
                > ld: library not found for -lmysqlclient_r
                > clang: error: linker command failed with exit code 1 (use -v to see invocation)
                

                and qmake command

                /Users/lorenko/Qt5.14.2/5.14.2/clang_64/bin/qmake -- MYSQL_INCDIR="/usr/local/mysql-8.0.19-macos10.15-x86_64/include" MYSQL_LIBDIR="/usr/local/mysql-8.0.19-macos10.15-x86_64/lib"
                

                same results

                QSqlDatabase: QMYSQL driver not loaded
                QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                
                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #8

                You have the plugin already.

                QSqlDatabase: available drivers: QSQLITE QMYSQL ...

                Have you debugged why it doesn't load, like @SGaist suggested?

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lorenko
                  wrote on last edited by
                  #9

                  @SGaist said in QMYSQL driver build problem:

                  Start your application with the QT_DEBUG_PLUGINS environment variable set to 1.

                  Ohh, sorry you're right and my apologies to @SGaist

                  QFactoryLoader::QFactoryLoader() checking directory path "/Users/lorenko/progetti/build-BoraApp-Desktop_Qt_5_14_2_clang_64bit-Debug/BoraApp.app/Contents/MacOS/sqldrivers" ...
                  Cannot load library /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib
                    Referenced from: /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                    Reason: image not found)
                  QLibraryPrivate::loadPlugin failed on "/Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib\n  Referenced from: /Users/lorenko/Qt5.14.2/5.14.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
                  QSqlDatabase: QMYSQL driver not loaded
                  QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
                  

                  The problem was solved copiyng mysql libraries to /usr/local/lib

                  thank you very much and sorry again

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

                    One thing you can do is use install_name_tool and update the MySQL library path to use the full path.

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

                    worldpieceW 1 Reply Last reply
                    1
                    • L Offline
                      L Offline
                      lorenko
                      wrote on last edited by
                      #11

                      Yes, best way, thx

                      1 Reply Last reply
                      0
                      • SGaistS SGaist

                        One thing you can do is use install_name_tool and update the MySQL library path to use the full path.

                        worldpieceW Offline
                        worldpieceW Offline
                        worldpiece
                        wrote on last edited by
                        #12
                        This post is deleted!
                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          MEMekaniske
                          wrote on last edited by
                          #13

                          @worldpiece said in QMYSQL driver build problem:

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

                          Hey, I did this successfully, like I think that you also did, as you have the QMYSQL driver.

                          I had to copy libmysql, from the MySQL Server dir to my exe /debug/release folder together with the dependency libs from openssl,
                          libssl-1_1-x64
                          libcrypto-1_1-x64

                          I also had to copy the qmysql drivers to a folder named sqldrivers my exe folder..

                          But a guy who just had this problem had to make fewer changes, all he needed to do was add the openssl libs to the exe/build folder, so maybe try that first.

                          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
                          • Unsolved