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. Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded
Forum Updated to NodeBB v4.3 + New Features

Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded

Scheduled Pinned Locked Moved Solved General and Desktop
40 Posts 5 Posters 9.0k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #17

    It's shown the Qt Creator documentation.

    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
    • SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by SPlatten
      #18

      @SGaist , I'm struggling with the documentation, the version of Qt Creator I'm using is:

      Qt Creator 4.7.0-rc1 (4.6.84)

      From the link posted I don't see, Projects > Build & Run > Run

      How do I get to this section?

      [Edit], found it, I'm so blind, I was looking for a menu option, it was right in front of me on the left vertical tool bar.

      Kind Regards,
      Sy

      1 Reply Last reply
      0
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by SPlatten
        #19

        @SPlatten said in Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded:

        QT_DEBUG_PLUGINS

        @SGaist , this is the output when the QT_DEBUG_PLUGINS is correctly added, I think I've isolated the problem, but not sure why its looking for this file and it doesn't exist::

        2018-10-10 10:30:42.060973+0100 SimonQtWidgets[2001:286805] Got keys from plugin meta data ("QPSQL7", "QPSQL")
        2018-10-10 10:30:42.060985+0100 SimonQtWidgets[2001:286805] QFactoryLoader::QFactoryLoader() checking directory path "/Users/simonplatten/build-SimonQtWidgets-Desktop_Qt_5_11_2_clang_64bit-Debug/SimonQtWidgets.app/Contents/MacOS/sqldrivers" ...
        2018-10-10 10:30:42.063252+0100 SimonQtWidgets[2001:286805] Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
          Referenced from: /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
          Reason: image not found)
        2018-10-10 10:30:42.063276+0100 SimonQtWidgets[2001:286805] QLibraryPrivate::loadPlugin failed on "/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n  Referenced from: /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
        2018-10-10 10:30:42.0
        63293+0100 SimonQtWidgets[2001:286805] QSqlDatabase: QMYSQL driver not loaded
        2018-10-10 10:30:42.063465+0100 SimonQtWidgets[2001:286805] QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
        

        The file it appears to be looking for which doesn't exist:

            /usr/local/mysql/lib/libmysqlclient.20.dylib
        

        There is no mysql folder in /usr/local/

        I just ran:

            find / -name mysql
        

        It returned:

            /usr/local/bin/mysql
        

        There are also:

        /usr/local/Cellar/mariadb/10.1.17/bin/mysql
        /usr/local/Cellar/mariadb/10.1.17/include/mysql
        /usr/local/Cellar/mariadb/10.1.17/share/mysql
        /usr/local/Cellar/mariadb/10.2.6/bin/mysql
        /usr/local/Cellar/mariadb/10.2.6/include/mysql
        /usr/local/Cellar/mariadb/10.2.6/include/mysql/mysql
        /usr/local/Cellar/mariadb/10.2.6/.bottle/etc/init.d/mysql
        /usr/local/Cellar/mariadb/10.2.6/.bottle/etc/logrotate.d/mysql
        /usr/local/Cellar/mariadb/10.2.6/share/mysql
        

        I also found this in share:

        lrwxr-xr-x    1 simonplatten  admin     36 10 Jun  2017 mysql -> ../Cellar/mariadb/10.2.6/share/mysql
        

        Kind Regards,
        Sy

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sunfluxgames
          wrote on last edited by
          #20

          Please make sure you complie the Qmysql plugin in qtbase folder

          Link x86 libs or x64 libs with whatever mysql you have installed on your system.

          Copy sqldriver folder to complier folder

          Should fix all sql drivers not finding the correct path locations.

          Also make sure you override the static qmysql plugins as there are static ones that come shipping with it.

          1 Reply Last reply
          1
          • SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by SPlatten
            #21

            @Sunfluxgames , I copied:

            libqsqlmysql.dylib
            

            to:

            ~/build-SimonQtWidgets-Desktop_Qt_5_11_2_clang_64bit-Debug
            

            The problem and reported errors haven't changed, still the same.

            Kind Regards,
            Sy

            JonBJ 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @Sunfluxgames , I copied:

              libqsqlmysql.dylib
              

              to:

              ~/build-SimonQtWidgets-Desktop_Qt_5_11_2_clang_64bit-Debug
              

              The problem and reported errors haven't changed, still the same.

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #22

              @SPlatten
              I do not use Mac or compile Qt.

              But it seems to me that the error message:

              Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
              

              is unequivocal. You need a libmysqlclient.20.dylib. (Moving just libqsqlmysql.dylib to somewhere is not going to address this.)

              Try Googling for libqsqlmysql. There are others asking about this being missing under Linux/MacOS. You may need to download it (apt-get under MacOS? I have no idea) given what you show from your find and/or see e.g. https://afshinm.name/2016/02/05/how-to-fix-library-not-loaded-libmysqlclient-18-dylib-in-mac-os-x/

              1 Reply Last reply
              1
              • S Offline
                S Offline
                Sunfluxgames
                wrote on last edited by
                #23
                ~/Qt/5.11.2/clang_64/bin/qmake "INCLUDEPATH += /usr/local/mysql/include/" "LIBS += -L/usr/local/mysql/" mysql.pro
                

                Complie mysql.pro in qtbase/sqldrivers

                And then:

                cp ~/Qt/5.11.2/Src/qtbase/plugins/sqldrivers/ ~/Qt/5.11.2/clang_64/plugins/sqldrivers/
                

                Also might need to copy them to the creator folder as well to debug inside creator.

                1 Reply Last reply
                0
                • SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #24

                  @Sunfluxgames , there i no /usr/local/mysql folder on my system, its MariaDB, when I ran:

                      ~./Qt/5.11.2/clang_64/bin/qmake "INCLUDEPATH += /usr/local/mysql/include/" "LIBS += -L/usr/local/mysql/" mysql.pro
                  

                  I got:

                      Cannot find file: mysql.pro.
                  

                  Kind Regards,
                  Sy

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

                    Before trying to build anything (you need to first download the sources for that). Please run your application with the QT_DEBUG_PLUGINS environment variable set to 1.

                    Click on the Project button on the vertical toolbar on the left of Qt Creator, and there you'll find the Build and Run settings. Modify the Environment in the Run settings.

                    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
                    • SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #26

                      @SGaist , I did that, hasn't helped.

                      Kind Regards,
                      Sy

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

                        It's not supposed to change anything in the application execution. The goal is to provide you with additional information about what is happening when plugins are getting or not loaded and from there help find what might be going wrong.

                        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
                        • SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by
                          #28

                          @SGaist said in Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded:

                          QT_DEBUG_PLUGINS

                          With QT_DEBUG_PLUGINS added to the environment the output when single stepping over:

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

                          Is:

                          2018-10-11 08:28:13.253913+0100 SimonQtWidgets[1031:41669] Got keys from plugin meta data ("QPSQL7", "QPSQL")
                          2018-10-11 08:28:13.253927+0100 SimonQtWidgets[1031:41669] QFactoryLoader::QFactoryLoader() checking directory path "/Users/simonplatten/build-SimonQtWidgets-Desktop_Qt_5_11_2_clang_64bit-Debug/SimonQtWidgets.app/Contents/MacOS/sqldrivers" ...
                          2018-10-11 08:28:13.255823+0100 SimonQtWidgets[1031:41669] Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
                            Referenced from: /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                            Reason: image not found)
                          2018-10-11 08:28:13.255844+0100 SimonQtWidgets[1031:41669] QLibraryPrivate::loadPlugin failed on "/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n  Referenced from: /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
                          2018-10-11 08:28:13.255
                          859+0100 SimonQtWidgets[1031:41669] QSqlDatabase: QMYSQL driver not loaded
                          2018-10-11 08:28:13.255885+0100 SimonQtWidgets[1031:41669] QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
                          

                          Kind Regards,
                          Sy

                          jsulmJ 1 Reply Last reply
                          0
                          • SPlattenS SPlatten

                            @SGaist said in Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded:

                            QT_DEBUG_PLUGINS

                            With QT_DEBUG_PLUGINS added to the environment the output when single stepping over:

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

                            Is:

                            2018-10-11 08:28:13.253913+0100 SimonQtWidgets[1031:41669] Got keys from plugin meta data ("QPSQL7", "QPSQL")
                            2018-10-11 08:28:13.253927+0100 SimonQtWidgets[1031:41669] QFactoryLoader::QFactoryLoader() checking directory path "/Users/simonplatten/build-SimonQtWidgets-Desktop_Qt_5_11_2_clang_64bit-Debug/SimonQtWidgets.app/Contents/MacOS/sqldrivers" ...
                            2018-10-11 08:28:13.255823+0100 SimonQtWidgets[1031:41669] Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
                              Referenced from: /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                              Reason: image not found)
                            2018-10-11 08:28:13.255844+0100 SimonQtWidgets[1031:41669] QLibraryPrivate::loadPlugin failed on "/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n  Referenced from: /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
                            2018-10-11 08:28:13.255
                            859+0100 SimonQtWidgets[1031:41669] QSqlDatabase: QMYSQL driver not loaded
                            2018-10-11 08:28:13.255885+0100 SimonQtWidgets[1031:41669] QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
                            
                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #29

                            @SPlatten said in Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded:

                            Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib

                            Do you have this lib in that location?

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

                            1 Reply Last reply
                            0
                            • SPlattenS Offline
                              SPlattenS Offline
                              SPlatten
                              wrote on last edited by
                              #30

                              @jsulm , No, I've no idea what this library is or where is comes from. The path /usr/local/mysql doesn't exist.

                              Kind Regards,
                              Sy

                              jsulmJ 1 Reply Last reply
                              0
                              • SPlattenS SPlatten

                                @jsulm , No, I've no idea what this library is or where is comes from. The path /usr/local/mysql doesn't exist.

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

                                @SPlatten This is the MySQL client library which is used by Qt to access MySQL databases. You need it if you want to use MySQL.

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

                                1 Reply Last reply
                                0
                                • SPlattenS Offline
                                  SPlattenS Offline
                                  SPlatten
                                  wrote on last edited by
                                  #32

                                  @jsulm said in Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded:

                                  libmysqlclient.20.dylib

                                  I've found what I think is the correct library on my system:

                                      /usr/local/Cellar/mariadb/10.2.6/lib/libmariadb.dylib
                                  

                                  I then tried:

                                      sudo ln -s /usr/local/Cellar/mariadb/10.2.6/lib/libmariadb.dylib /usr/local/lib/libmysqlclient.20.dylib
                                  

                                  Re-ran in debug and the problem has changed, looks like I'm using the wrong library now:

                                  2018-10-11 09:15:08.331712+0100 SimonQtWidgets[1644:135071] Got keys from plugin meta data ("QPSQL7", "QPSQL")
                                  2018-10-11 09:15:08.331726+0100 SimonQtWidgets[1644:135071] QFactoryLoader::QFactoryLoader() checking directory path "/Users/simonplatten/build-SimonQtWidgets-Desktop_Qt_5_11_2_clang_64bit-Debug/SimonQtWidgets.app/Contents/MacOS/sqldrivers" ...
                                  2018-10-11 09:15:08.347152+0100 SimonQtWidgets[1644:135071] Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib
                                    Referenced from: /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib
                                    Reason: Incompatible library version: libqsqlmysql.dylib requires version 20.0.0 or later, but libmysqlclient.20.dylib provides version 3.0.0)
                                  2018-10-11 09:15:08.347182+0100 SimonQtWidgets[1644:135071] QLibraryPrivate::loadPlugin failed on "/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/simonplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: /usr/local/mysql/lib/libmysqlclient.20.dylib\n  Referenced from: /Users/sim
                                  onplatten/Qt/5.11.2/clang_64/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: Incompatible library version: libqsqlmysql.dylib requires version 20.0.0 or later, but libmysqlclient.20.dylib provides version 3.0.0)"
                                  2018-10-11 09:15:08.347201+0100 SimonQtWidgets[1644:135071] QSqlDatabase: QMYSQL driver not loaded
                                  2018-10-11 09:15:08.347228+0100 SimonQtWidgets[1644:135071] QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QPSQL QPSQL7
                                  

                                  Kind Regards,
                                  Sy

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

                                    Don't use ln that won't help, use install_name_tool and update the path in libqsqlmysql.dylib to match what you have on your system.

                                    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
                                    • SPlattenS Offline
                                      SPlattenS Offline
                                      SPlatten
                                      wrote on last edited by SPlatten
                                      #34

                                      @SGaist, thank you, do you have an example? How do I achieve this?

                                      Kind Regards,
                                      Sy

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

                                        Did you read the tool's help ?

                                        install_name_tool -change /usr/local/mysql/lib/libmysqlclient.20.dylib /path/to/mariadb/libmariadbclient.X.dylib /Users/hasan/Qt5.9.1/5.9.1/clang_64/plugins/sqldrivers/libqsqlmysql.dylib

                                        Note that MariaDB should be a drop-in replacement however I haven't tried to "re-link" to a library that has different name (just a different compatible version number) so you may have other surprises.

                                        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
                                        • SPlattenS Offline
                                          SPlattenS Offline
                                          SPlatten
                                          wrote on last edited by SPlatten
                                          #36

                                          @SPlatten said in Qt5.11.2, QSqlDatabase, QMYSQL, Driver not loaded:

                                          2018-10-11 09:15:08.331712+0100 SimonQtWidgets[1644:135071] Got keys from plugin meta data ("QPSQL7", "QPSQL")
                                          2018-10-11 09:15:08.331726+0100 SimonQtWidgets[1644:135071] QFactoryLoader::QFact

                                          @SGaist

                                          I'm struggling, the only libmariadbclient I can find on my entire system is:

                                              /usr/local/Cellar/mariadb/10.2.6/lib/libmariadbclient.a
                                          

                                          Kind Regards,
                                          Sy

                                          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