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. Can't create MYSQL plugin in MacOS.

Can't create MYSQL plugin in MacOS.

Scheduled Pinned Locked Moved Solved General and Desktop
mysql drivermac os 10.15.7qt6.4.0
7 Posts 3 Posters 779 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.
  • S Offline
    S Offline
    superg
    wrote on 24 Nov 2022, 22:52 last edited by superg
    #1

    Hello,
    For the past two days I've been trying to create the MYSQL driver following this official QT documentation. The problem is when I try to execute the following command:

    /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.<so|dylib>"
    

    I get the error:

    CMake Error: The source directory "/Users/santiagocarlos/Qt/build-sqldrivers/Qt/6.4.1/Src/qtbase/src/plugins/sqldrivers" does not exist.
    
    

    Can someone please help me with this? I really don't know what to do.

    A few this I want to clarify:

    • I have to execute the qt-cmake script with the prefix /Users/Santiagocarlos/Qt/6.4.1/macos/bin/qt-cmake because adding the path to qt-cmake with the command "export PATH=$PATH:~/Users/santiagocarlos/Qt/6.4.1/macos/bin/qt-cmake" doesn't work. I just get "zsh: command not found: qt-cmake"
    • I'm using Qt 6.4.1 in MacOS Catalina 10.15.7.

    Here is a visual example:

    Screen Shot 2022-11-24 at 19.49.12 PM.png

    The folder build-sqldrivers is created on Users/santiagocarlos.

    Thank you in advance.

    UPDATE:

    I tried running qt-cmake from my directory Users/santiagocarlos and it worked, but I got the following error:

    -- Configuring done
    -- Generating done
    CMake Error:
      Running
    
       '/usr/local/bin/ninja' '-C' '/Users/santiagocarlos' '-t' 'recompact'
    
      failed with:
    
       ninja: error: build.ninja:170: expected newline, got '|'
    

    Does anyone know how to fix this?

    J 1 Reply Last reply 25 Nov 2022, 06:23
    0
    • S superg
      24 Nov 2022, 22:52

      Hello,
      For the past two days I've been trying to create the MYSQL driver following this official QT documentation. The problem is when I try to execute the following command:

      /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.<so|dylib>"
      

      I get the error:

      CMake Error: The source directory "/Users/santiagocarlos/Qt/build-sqldrivers/Qt/6.4.1/Src/qtbase/src/plugins/sqldrivers" does not exist.
      
      

      Can someone please help me with this? I really don't know what to do.

      A few this I want to clarify:

      • I have to execute the qt-cmake script with the prefix /Users/Santiagocarlos/Qt/6.4.1/macos/bin/qt-cmake because adding the path to qt-cmake with the command "export PATH=$PATH:~/Users/santiagocarlos/Qt/6.4.1/macos/bin/qt-cmake" doesn't work. I just get "zsh: command not found: qt-cmake"
      • I'm using Qt 6.4.1 in MacOS Catalina 10.15.7.

      Here is a visual example:

      Screen Shot 2022-11-24 at 19.49.12 PM.png

      The folder build-sqldrivers is created on Users/santiagocarlos.

      Thank you in advance.

      UPDATE:

      I tried running qt-cmake from my directory Users/santiagocarlos and it worked, but I got the following error:

      -- Configuring done
      -- Generating done
      CMake Error:
        Running
      
         '/usr/local/bin/ninja' '-C' '/Users/santiagocarlos' '-t' 'recompact'
      
        failed with:
      
         ninja: error: build.ninja:170: expected newline, got '|'
      

      Does anyone know how to fix this?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 25 Nov 2022, 06:23 last edited by jsulm
      #2

      @superg said in Can't create MYSQL plugin in MacOS.:

      /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.<so|dylib>"

      Check the paths you have in this command: many of them do not have leading /
      For example: -DCMAKE_INSTALL_PREFIX=Users/santiagocarlos/Qt/6.4.1/macos

      Also, here: /lib/libmysqlclient.<so|dylib> you need to change to /lib/libmysqlclient.dylib
      <so|dylib> is just a placeholder and you need to change it to what is used on your system (MacOS uses dylib extension).

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

      S 2 Replies Last reply 25 Nov 2022, 07:10
      0
      • J jsulm
        25 Nov 2022, 06:23

        @superg said in Can't create MYSQL plugin in MacOS.:

        /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.<so|dylib>"

        Check the paths you have in this command: many of them do not have leading /
        For example: -DCMAKE_INSTALL_PREFIX=Users/santiagocarlos/Qt/6.4.1/macos

        Also, here: /lib/libmysqlclient.<so|dylib> you need to change to /lib/libmysqlclient.dylib
        <so|dylib> is just a placeholder and you need to change it to what is used on your system (MacOS uses dylib extension).

        S Offline
        S Offline
        superg
        wrote on 25 Nov 2022, 07:10 last edited by
        #3

        @jsulm thank you very much for your help, the drivers creation worked. Nonetheless, I have a new problem. When I try to make connection it still tells me the driver is not loaded, but it shows that it's available.
        This is the output:

        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-11-25 04:04:43.910863-0300 ProyectoPola[84792:1138343] QSqlDatabase: QMYSQL driver not loaded
        2022-11-25 04:04:43.910907-0300 ProyectoPola[84792:1138343] QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
        2022-11-25 04:04:43.910951-0300 ProyectoPola[84792:1138343] db connection false
        

        Do you know how can I solve this? I've tried with the following commands, but it didn't do anything.

        1. cd /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers
        
        2. install_name_tool -change libmysqlclient.21.dylib /usr/local/mysql/lib/libmysqlclient.21.dylib /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib
        

        Thanks in advance.

        J 1 Reply Last reply 25 Nov 2022, 08:05
        0
        • S superg
          25 Nov 2022, 07:10

          @jsulm thank you very much for your help, the drivers creation worked. Nonetheless, I have a new problem. When I try to make connection it still tells me the driver is not loaded, but it shows that it's available.
          This is the output:

          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-11-25 04:04:43.910863-0300 ProyectoPola[84792:1138343] QSqlDatabase: QMYSQL driver not loaded
          2022-11-25 04:04:43.910907-0300 ProyectoPola[84792:1138343] QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
          2022-11-25 04:04:43.910951-0300 ProyectoPola[84792:1138343] db connection false
          

          Do you know how can I solve this? I've tried with the following commands, but it didn't do anything.

          1. cd /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers
          
          2. install_name_tool -change libmysqlclient.21.dylib /usr/local/mysql/lib/libmysqlclient.21.dylib /Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlmysql.dylib
          

          Thanks in advance.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 25 Nov 2022, 08:05 last edited by
          #4

          @superg said in Can't create MYSQL plugin in MacOS.:

          Do you know how can I solve this?

          Probably MySQL client lib is not found.
          Set QT_DEBUG_PLUGINS variable before starting your app and check the output: you should see why the plug-in was not loaded. See https://doc.qt.io/qt-6/debug.html

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

          S 1 Reply Last reply 25 Nov 2022, 21:21
          0
          • J jsulm
            25 Nov 2022, 08:05

            @superg said in Can't create MYSQL plugin in MacOS.:

            Do you know how can I solve this?

            Probably MySQL client lib is not found.
            Set QT_DEBUG_PLUGINS variable before starting your app and check the output: you should see why the plug-in was not loaded. See https://doc.qt.io/qt-6/debug.html

            S Offline
            S Offline
            superg
            wrote on 25 Nov 2022, 21:21 last edited by
            #5

            @jsulm said in Can't create MYSQL plugin in MacOS.:

            https://doc.qt.io/qt-6/debug.html

            Thanks for the help. I set the enviroment variable QT_DEBUG_PLUGINS and I found the following:

            2022-11-25 18:03:54.665614-0300 ProyectoPola[85531:1148132] [qt.core.plugin.factoryloader] Got keys from plugin meta data QList("QMYSQL", "QMARIADB")
            2022-11-25 18:03:54.665680-0300 ProyectoPola[85531:1148132] [qt.core.plugin.factoryloader] looking at "/Users/santiagocarlos/Qt/6.4.1/macos/plugins/sqldrivers/libqsqlodbc.dylib"
            2022-11-25 18:03:54.665830-0300 ProyectoPola[85531:1148132] [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
            }
            

            So, it finds a key for QMYSQL, but a few lines below I get this:

            2022-11-25 18:03:54.673034-0300 ProyectoPola[85531:1148132] [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-11-25 18:03:54.673093-0300 ProyectoPola[85531:1148132] [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-11-25 18:03:54.673121-0300 ProyectoPola[85531:1148132] QSqlDatabase: QMYSQL driver not loaded
            2022-11-25 18:03:54.673168-0300 ProyectoPola[85531:1148132] QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL
            

            So, when I try to add a database, Qt doesn't find the QMySQL driver.
            Do you know how to solve this? I tried with the commands mentioned in my past reply with no luck, and every other solution that I found it's for windows, they do not work for me.
            Thanks in advance.

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on 26 Nov 2022, 02:43 last edited by
              #6

              Hi, to get that missing the driver dll (ibmysqlclient.21.dylib) perhaps you have not installed MySQL on your Catalina PC? For more see here

              1 Reply Last reply
              0
              • J jsulm
                25 Nov 2022, 06:23

                @superg said in Can't create MYSQL plugin in MacOS.:

                /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.<so|dylib>"

                Check the paths you have in this command: many of them do not have leading /
                For example: -DCMAKE_INSTALL_PREFIX=Users/santiagocarlos/Qt/6.4.1/macos

                Also, here: /lib/libmysqlclient.<so|dylib> you need to change to /lib/libmysqlclient.dylib
                <so|dylib> is just a placeholder and you need to change it to what is used on your system (MacOS uses dylib extension).

                S Offline
                S Offline
                superg
                wrote on 5 Dec 2022, 22:06 last edited by superg 12 May 2022, 22:09
                #7
                This post is deleted!
                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