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. Stuck creating MySQL drivers on Mac OS
QtWS25 Last Chance

Stuck creating MySQL drivers on Mac OS

Scheduled Pinned Locked Moved Solved General and Desktop
macosmacosxmac os 10.15.7mysql driverqt6.4.1
11 Posts 2 Posters 2.7k 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.
  • supergS Offline
    supergS Offline
    superg
    wrote on last edited by superg
    #1

    Hello, I've been trying to create the MySQL drivers for QT 6.4 on Mac OS Catalina, yet when i follow the instructions specified here, I get stuck executing the command

    qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
    

    This is a step by step of what I have done.

    • Open Terminal
    • Execute mkdir build-sqldrivers (Thus, creating the folder build-sqldrivers in /Users/santiagocarlos/)
    • Execute cd build-sqldrivers
    • Execute the command below:
    /Users/Santiagocarlos/Qt/6.4.1/macos/bin/qt-cmake -G Ninja /Users/Santiagocarlos/Qt/6.4.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/Santiagocarlos/Qt/6.4.1/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib”
    

    And this is where I got stuck. The only thing I can see in the terminal is this:
    Screen Shot 2022-12-05 at 18.41.37 PM.png
    Here I don't know what to do. It doesn't matter what I try or type, when I press enter I get a new line with the dquote> prefix. This is another example:
    Screen Shot 2022-12-06 at 02.09.59 AM.png
    Here I tried typing the commands cmake --build . and cmake --install . like it says in the Qt documentation. After this, if I finish the execution with Ctrl+C and I press de "up" arrow to see the last command I typed, I get this:
    Screen Shot 2022-12-06 at 02.10.10 AM.png
    Which is weird, like it's stored or something.
    I been dealing with this for the past few days and still don't get it, nor find any answer online.

    Does anybody know what should I do here? I'm really confused. Am I creating the folder build-sqldrivers in the correct directory? Should I type something special here? I appreciate any kind of help or guidance.

    Thank you all in advance.

    jsulmJ 1 Reply Last reply
    0
    • supergS superg

      Hello, I've been trying to create the MySQL drivers for QT 6.4 on Mac OS Catalina, yet when i follow the instructions specified here, I get stuck executing the command

      qt-cmake -G Ninja <qt_installation_path>/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>/<platform> -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.<so|dylib>"
      

      This is a step by step of what I have done.

      • Open Terminal
      • Execute mkdir build-sqldrivers (Thus, creating the folder build-sqldrivers in /Users/santiagocarlos/)
      • Execute cd build-sqldrivers
      • Execute the command below:
      /Users/Santiagocarlos/Qt/6.4.1/macos/bin/qt-cmake -G Ninja /Users/Santiagocarlos/Qt/6.4.1/Src/qtbase/src/plugins/sqldrivers -DCMAKE_INSTALL_PREFIX=/Users/Santiagocarlos/Qt/6.4.1/macos -DMySQL_INCLUDE_DIR="/usr/local/mysql/include" -DMySQL_LIBRARY="/usr/local/mysql/lib/libmysqlclient.dylib”
      

      And this is where I got stuck. The only thing I can see in the terminal is this:
      Screen Shot 2022-12-05 at 18.41.37 PM.png
      Here I don't know what to do. It doesn't matter what I try or type, when I press enter I get a new line with the dquote> prefix. This is another example:
      Screen Shot 2022-12-06 at 02.09.59 AM.png
      Here I tried typing the commands cmake --build . and cmake --install . like it says in the Qt documentation. After this, if I finish the execution with Ctrl+C and I press de "up" arrow to see the last command I typed, I get this:
      Screen Shot 2022-12-06 at 02.10.10 AM.png
      Which is weird, like it's stored or something.
      I been dealing with this for the past few days and still don't get it, nor find any answer online.

      Does anybody know what should I do here? I'm really confused. Am I creating the folder build-sqldrivers in the correct directory? Should I type something special here? I appreciate any kind of help or guidance.

      Thank you all in advance.

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

      @superg Take a close look at the last parameter: you terminate the string with wrong " character, so the string is not terminated and you get dquote.

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

      supergS 1 Reply Last reply
      1
      • jsulmJ jsulm

        @superg Take a close look at the last parameter: you terminate the string with wrong " character, so the string is not terminated and you get dquote.

        supergS Offline
        supergS Offline
        superg
        wrote on last edited by
        #3

        @jsulm Thanks! That did it. Although now I have a new problem, I have successfully installed the MySQL driver, but when I try to load it I still get the error QSqlDatabase: QMYSQL driver not loaded.
        I set the QT_DEBUG_PLUGINS to 1 and I get the following:

        2022-12-06 03:41:51.207332-0300 ProyectoPola[33637:303361] [qt.core.library] "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib" cannot load: Cannot load library /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib
          Referenced from: /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib
          Reason: image not found)
        2022-12-06 03:41:51.207385-0300 ProyectoPola[33637:303361] [qt.core.plugin.loader] QLibraryPrivate::loadPlugin failed on "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib\n  Referenced from: /Users/santiagocarlos/Qt/6.4.1/macos/p
        lugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
        2022-12-06 03:41:51.207436-0300 ProyectoPola[33637:303361] QSqlDatabase: QMYSQL driver not loaded
        2022-12-06 03:41:51.207494-0300 ProyectoPola[33637:303361] QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
        2022-12-06 03:41:51.207549-0300 ProyectoPola[33637:303361] db connection false
        

        So, it seems like I can't load the driver, even though it's available.
        Any idea how to solve this?
        Thank you.

        jsulmJ 1 Reply Last reply
        0
        • supergS superg

          @jsulm Thanks! That did it. Although now I have a new problem, I have successfully installed the MySQL driver, but when I try to load it I still get the error QSqlDatabase: QMYSQL driver not loaded.
          I set the QT_DEBUG_PLUGINS to 1 and I get the following:

          2022-12-06 03:41:51.207332-0300 ProyectoPola[33637:303361] [qt.core.library] "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib" cannot load: Cannot load library /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib
            Referenced from: /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib
            Reason: image not found)
          2022-12-06 03:41:51.207385-0300 ProyectoPola[33637:303361] [qt.core.plugin.loader] QLibraryPrivate::loadPlugin failed on "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib\n  Referenced from: /Users/santiagocarlos/Qt/6.4.1/macos/p
          lugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
          2022-12-06 03:41:51.207436-0300 ProyectoPola[33637:303361] QSqlDatabase: QMYSQL driver not loaded
          2022-12-06 03:41:51.207494-0300 ProyectoPola[33637:303361] QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
          2022-12-06 03:41:51.207549-0300 ProyectoPola[33637:303361] db connection false
          

          So, it seems like I can't load the driver, even though it's available.
          Any idea how to solve this?
          Thank you.

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

          @superg said in Stuck creating MySQL drivers on Mac OS:

          Library not loaded: @rpath/libmysqlclient.21.dylib

          The MySQL client library is not found. It is located in /usr/local/mysql which is not a path searched by default for libraries. There are different ways to solve this:

          • Set LD_LIBRARY_PATH environment variable, so it points to /usr/local/mysql
          • Copy the MySQL client library to your build folder
          • Copy the MySQL client library to a folder searched by the system for libraries (like /usr/lib)

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

          supergS 2 Replies Last reply
          0
          • jsulmJ jsulm

            @superg said in Stuck creating MySQL drivers on Mac OS:

            Library not loaded: @rpath/libmysqlclient.21.dylib

            The MySQL client library is not found. It is located in /usr/local/mysql which is not a path searched by default for libraries. There are different ways to solve this:

            • Set LD_LIBRARY_PATH environment variable, so it points to /usr/local/mysql
            • Copy the MySQL client library to your build folder
            • Copy the MySQL client library to a folder searched by the system for libraries (like /usr/lib)
            supergS Offline
            supergS Offline
            superg
            wrote on last edited by superg
            #5

            @jsulm Ok, I tried with the two first steps with no luck. I will try the third one later, I have to deactivate de SIP system of my mac.
            Here is a screenshot were I show how I set LD_LIBRARY_PATH:
            Screen Shot 2022-12-06 at 15.25.28 PM.png
            This is in "Run" under "Build & Run" in "projects".
            I also copied the file libmysqlclient.21.dylib (found in /usr/local/mysql/lib) to the build folder of my project.
            Have I done something wrong?
            Thanks.

            jsulmJ 1 Reply Last reply
            0
            • supergS superg

              @jsulm Ok, I tried with the two first steps with no luck. I will try the third one later, I have to deactivate de SIP system of my mac.
              Here is a screenshot were I show how I set LD_LIBRARY_PATH:
              Screen Shot 2022-12-06 at 15.25.28 PM.png
              This is in "Run" under "Build & Run" in "projects".
              I also copied the file libmysqlclient.21.dylib (found in /usr/local/mysql/lib) to the build folder of my project.
              Have I done something wrong?
              Thanks.

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

              @superg Please check again with QT_DEBUG_PLUGINS set to see why it fails now.

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

              supergS 1 Reply Last reply
              0
              • jsulmJ jsulm

                @superg Please check again with QT_DEBUG_PLUGINS set to see why it fails now.

                supergS Offline
                supergS Offline
                superg
                wrote on last edited by
                #7

                @jsulm Ok, so this is what I get:

                2022-12-07 22:13:59.642409-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader] Got keys from plugin meta data QList("QSQLITE")
                2022-12-07 22:13:59.642606-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader]
                 looking at "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib"
                2022-12-07 22:13:59.643509-0300 ProyectoPola[49706:477072] [qt.core.plugin.loader] Found metadata in lib /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib, metadata=
                {
                    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                    "MetaData": {
                        "Keys": [
                            "QMYSQL",
                            "QMARIADB"
                        ]
                    },
                    "archlevel": 2,
                    "className": "QMYSQLDriverPlugin",
                    "debug": false,
                    "version": 394240
                }
                2022-12-07 22:13:59.643583-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader] Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
                2022-12-07 22:13:59.643700-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader] looking at "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlodbc.dylib"
                2022-12-07 22:13:59.644751-0300 ProyectoPola[49706:477072] [qt.core.plugin.loader] Found metadata in lib /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
                {
                    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                    "MetaData": {
                        "Keys": [
                            "QODBC"
                        ]
                    },
                    "archlevel": 2,
                    "className": "QODBCDriverPlugin",
                    "debug": false,
                    "version": 394240
                }
                2022-12-07 22:13:59.644800-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader] Got keys from plugin meta data QList("QODBC")
                2022-12-07 22:13:59.644947-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader] looking at "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlpsql.dylib"
                2022-12-07 22:13:59.645977-0300 ProyectoPola[49706:477072] [qt.core.plugin.loader] Found metadata in lib /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlpsql.dylib, metadata=
                {
                    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                    "MetaData": 
                {
                        "Keys": [
                            "QPSQL"
                        ]
                    },
                    "archlevel": 2,
                    "className": "QPSQLDriverPlugin",
                    "debug": false,
                    "version": 394240
                }
                2022-12-07 22:13:59.646016-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader] Got keys from plugin meta data QList("QPSQL")
                2022-12-07 22:13:59.646039-0300 ProyectoPola[49706:477072] [qt.core.plugin.factoryloader] checking directory path "/Users/santiagocarlos/Trabajo/Polarímetro/build-ProyectoPola-Qt_6_4_1_for_macOS-Debug/ProyectoPola.app/Contents/MacOS/sqldrivers" ...
                2022-12-07 22:13:59.653530-0300 ProyectoPola[49706:477072] [qt.core.library] "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib" cannot load: Cannot load library /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib
                  Referenced from: /Users/santiagocarlos/Qt/6.4.1/macos/plugin
                s/sqldrivers/libqsqlmysql.dylib
                  Reason: image not found)
                2022-12-07 22:13:59.653574-0300 ProyectoPola[49706:477072] [qt.core.plugin.loader] QLibraryPrivate::loadPlugin failed on "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib" : "Cannot load library /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib: (dlopen(/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib, 133): Library not loaded: @rpath/libmysqlclient.21.dylib\n  Referenced from: /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib\n  Reason: image not found)"
                2022-12-07 22:13:59.653614-0300 ProyectoPola[49706:477072] QSqlDatabase: QMYSQL driver not loaded
                2022-12-07 22:13:59.653662-0300 ProyectoPola[49706:477072] QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
                2022-12-07 22:13:59.653704-0300 ProyectoPola[49706:477072] db connection false
                

                I think the output is basically the same as before I followed the steps you recommended, that why I asked if I had done something wrong.
                Thanks again.

                1 Reply Last reply
                0
                • jsulmJ jsulm

                  @superg said in Stuck creating MySQL drivers on Mac OS:

                  Library not loaded: @rpath/libmysqlclient.21.dylib

                  The MySQL client library is not found. It is located in /usr/local/mysql which is not a path searched by default for libraries. There are different ways to solve this:

                  • Set LD_LIBRARY_PATH environment variable, so it points to /usr/local/mysql
                  • Copy the MySQL client library to your build folder
                  • Copy the MySQL client library to a folder searched by the system for libraries (like /usr/lib)
                  supergS Offline
                  supergS Offline
                  superg
                  wrote on last edited by
                  #8

                  @jsulm said in Stuck creating MySQL drivers on Mac OS:

                  • Copy the MySQL client library to your build folder
                  • Copy the MySQL client library to a folder searched by the system for libraries (like /usr/lib)

                  I have a question regarding this. What exactly do you mean by "Copy the MySQL client library to.."?
                  Are you referring to the file libmysqlclient.21.dylib found in /usr/local/mysql/lib? because that's what I copied. Should I copy the hole folder or something like that?

                  Thanks in advance.

                  jsulmJ 1 Reply Last reply
                  0
                  • supergS superg

                    @jsulm said in Stuck creating MySQL drivers on Mac OS:

                    • Copy the MySQL client library to your build folder
                    • Copy the MySQL client library to a folder searched by the system for libraries (like /usr/lib)

                    I have a question regarding this. What exactly do you mean by "Copy the MySQL client library to.."?
                    Are you referring to the file libmysqlclient.21.dylib found in /usr/local/mysql/lib? because that's what I copied. Should I copy the hole folder or something like that?

                    Thanks in advance.

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

                    @superg said in Stuck creating MySQL drivers on Mac OS:

                    Are you referring to the file libmysqlclient.21.dylib

                    Yes.
                    "Should I copy the hole folder or something like that?" - maybe, depends whether libmysqlclient.21.dylib depends on other libraries in that folder.

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

                    supergS 1 Reply Last reply
                    0
                    • supergS Offline
                      supergS Offline
                      superg
                      wrote on last edited by
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @superg said in Stuck creating MySQL drivers on Mac OS:

                        Are you referring to the file libmysqlclient.21.dylib

                        Yes.
                        "Should I copy the hole folder or something like that?" - maybe, depends whether libmysqlclient.21.dylib depends on other libraries in that folder.

                        supergS Offline
                        supergS Offline
                        superg
                        wrote on last edited by
                        #11

                        I just solved the issue following this video. Using the command provided in solution 1 did the trick.
                        The command I used is the following:

                        sudo ln -s /usr/local/mysql/lib/libmysqlclient.21.dylib /usr/local/lib/libmysqlclient.21.dylib
                        

                        The explanation of how this works is in that video, for anyone stepping with this problem in the future.
                        Thanks @jsulm for your help and time.

                        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