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. MySQL driver detected but not loading on MacOS
Forum Updated to NodeBB v4.3 + New Features

MySQL driver detected but not loading on MacOS

Scheduled Pinned Locked Moved Unsolved General and Desktop
62 Posts 8 Posters 14.5k 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.
  • SGaistS SGaist

    You need to build that targeting x86_64 not ARM.

    V Offline
    V Offline
    Vince2480
    wrote on last edited by
    #34

    @SGaist Are you saying MySql plugin can't be built for M1?

    jsulmJ 1 Reply Last reply
    0
    • V Vince2480

      @SGaist Are you saying MySql plugin can't be built for M1?

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

      @Vince2480 said in MySQL driver detected but not loading on MacOS:

      Are you saying MySql plugin can't be built for M1?

      No, that's not what @SGaist is saying.
      The thing is that you have x86_64 Qt, right? If so, then you also need x86_64 build of the MySql plug-in.

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

      V 1 Reply Last reply
      1
      • jsulmJ jsulm

        @Vince2480 said in MySQL driver detected but not loading on MacOS:

        Are you saying MySql plugin can't be built for M1?

        No, that's not what @SGaist is saying.
        The thing is that you have x86_64 Qt, right? If so, then you also need x86_64 build of the MySql plug-in.

        V Offline
        V Offline
        Vince2480
        wrote on last edited by
        #36

        @jsulm I see.

        1 Reply Last reply
        0
        • I Offline
          I Offline
          In-Gee
          wrote on last edited by
          #37

          I am also faced with the similar problems and I have got no clear answers from Qt person. In my case, my configuration is

          macOS Monterey with Intel cpu,
          PostgreSQL is running on docker with the official image Postgres:latest, i.e., PostgreSQL 14.5, which was updated yesterday in my Mac.

          The day before yesterday, my code has worked fine. There was no problem. Yesterday, I changed the PostgreSQL docker image to be the newer version, "postgres:latest". No source code of my app has been changed. So, I have tried to remove the Qt installs it again several times.

          My final choice is to downgrade the PostgreSQL docker image to the "Postgres:14" for which I wish to work fine. If this treatment works, the QPSQL driver code or driver selection procedure has serious problem conceptually. A complete redesign may be necessary.

          Let me give you the result tomorrow.

          jsulmJ 1 Reply Last reply
          0
          • I In-Gee

            I am also faced with the similar problems and I have got no clear answers from Qt person. In my case, my configuration is

            macOS Monterey with Intel cpu,
            PostgreSQL is running on docker with the official image Postgres:latest, i.e., PostgreSQL 14.5, which was updated yesterday in my Mac.

            The day before yesterday, my code has worked fine. There was no problem. Yesterday, I changed the PostgreSQL docker image to be the newer version, "postgres:latest". No source code of my app has been changed. So, I have tried to remove the Qt installs it again several times.

            My final choice is to downgrade the PostgreSQL docker image to the "Postgres:14" for which I wish to work fine. If this treatment works, the QPSQL driver code or driver selection procedure has serious problem conceptually. A complete redesign may be necessary.

            Let me give you the result tomorrow.

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

            @In-Gee said in MySQL driver detected but not loading on MacOS:

            I am also faced with the similar problems

            Driver not loaded?
            Changing the PostgreSQL server should not have any influence on whether the Qt driver plug-in can be loaded or not. Are you sure you have same problem as in this thread? Did you verify that the PostgreSQL plug-in can't be loaded?

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

            I 1 Reply Last reply
            0
            • jsulmJ jsulm

              @In-Gee said in MySQL driver detected but not loading on MacOS:

              I am also faced with the similar problems

              Driver not loaded?
              Changing the PostgreSQL server should not have any influence on whether the Qt driver plug-in can be loaded or not. Are you sure you have same problem as in this thread? Did you verify that the PostgreSQL plug-in can't be loaded?

              I Offline
              I Offline
              In-Gee
              wrote on last edited by
              #39

              @jsulm I just fixed the problem. Let me just explain how I found the problem step by step. (macOS)

              1. I prefer the Docker base PostgreSQL and install the Homebrew version of PostgreSQL. This is convenient to me because every upgrade apps can be done by a single command, $ brew upgrade.
              2. I activated QT_DEBUG_PLUGINS = 1 in the Qt Creator Environment setting. I have struggled to figure out how to do it, because I am a beginner for the Qt development situation. I have not understand what your are talking about.
              3. I followed the detailed debug message and found out the problem is the Qt is looking for the relevant QPSQL library based on the assumption such that the user has installed the PostgreSQL by using the PostgreSQL App.
              4. Problem is here: The Qt engineers could give a priority to the PostgreSQL.App installation but they has to consider the directory search for the users with Homebrew or the other installation methods as well.
              5. So I installed the PostgreSQL.App by downloading from the PostgreSQL website, stop the existing docker, runt the PostgreSQL.App and stop it followed by run the docker again. Then I compiled my source code again and I got it.
              6. It is recommended to consider the configuration the QPSQL driver, and also the other drivers, other mfethod/directory installations. The Unix command, "which", may give the hint to figure out the user preference. I hope the Qt engineers may consider the various situations with little bit clever way.

              Thanks for your interests.

              jsulmJ 1 Reply Last reply
              0
              • I In-Gee

                @jsulm I just fixed the problem. Let me just explain how I found the problem step by step. (macOS)

                1. I prefer the Docker base PostgreSQL and install the Homebrew version of PostgreSQL. This is convenient to me because every upgrade apps can be done by a single command, $ brew upgrade.
                2. I activated QT_DEBUG_PLUGINS = 1 in the Qt Creator Environment setting. I have struggled to figure out how to do it, because I am a beginner for the Qt development situation. I have not understand what your are talking about.
                3. I followed the detailed debug message and found out the problem is the Qt is looking for the relevant QPSQL library based on the assumption such that the user has installed the PostgreSQL by using the PostgreSQL App.
                4. Problem is here: The Qt engineers could give a priority to the PostgreSQL.App installation but they has to consider the directory search for the users with Homebrew or the other installation methods as well.
                5. So I installed the PostgreSQL.App by downloading from the PostgreSQL website, stop the existing docker, runt the PostgreSQL.App and stop it followed by run the docker again. Then I compiled my source code again and I got it.
                6. It is recommended to consider the configuration the QPSQL driver, and also the other drivers, other mfethod/directory installations. The Unix command, "which", may give the hint to figure out the user preference. I hope the Qt engineers may consider the various situations with little bit clever way.

                Thanks for your interests.

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

                @In-Gee said in MySQL driver detected but not loading on MacOS:

                I hope the Qt engineers may consider the various situations with little bit clever way

                You could file a change request in Qt Bug Tracker: https://bugreports.qt.io/secure/Dashboard.jspa

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

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  juneleung
                  wrote on last edited by
                  #41

                  I had a similar problem,
                  When I packaged the postgresql program, it was fine to run it locally, but when I opened the program on another computer, it prompted
                  "QSqlDatabase: QPSQL driver not loaded.
                  QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7",
                  it seems that the driver of postgresql is not loaded.
                  Why this the problem happened? Is there something wrong with the package? How should I set it?
                  Could anyone guide me how to solve it?

                  SGaistS 1 Reply Last reply
                  0
                  • J juneleung

                    I had a similar problem,
                    When I packaged the postgresql program, it was fine to run it locally, but when I opened the program on another computer, it prompted
                    "QSqlDatabase: QPSQL driver not loaded.
                    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7",
                    it seems that the driver of postgresql is not loaded.
                    Why this the problem happened? Is there something wrong with the package? How should I set it?
                    Could anyone guide me how to solve it?

                    SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #42

                    @juneleung hi and welcome to devnet,

                    You have to deploy the PostgreSQL library along your application. Did you use macdeployqt to deploy your application ?

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

                    J 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      @juneleung hi and welcome to devnet,

                      You have to deploy the PostgreSQL library along your application. Did you use macdeployqt to deploy your application ?

                      J Offline
                      J Offline
                      juneleung
                      wrote on last edited by
                      #43

                      Hi @SGaist
                      Yes, i have use macdeployqt to make it to a dmg file.
                      but when open it in another MacBook, it cant link with sql and notice driven not loaded driven not loaded.

                      artwawA 1 Reply Last reply
                      0
                      • J juneleung

                        Hi @SGaist
                        Yes, i have use macdeployqt to make it to a dmg file.
                        but when open it in another MacBook, it cant link with sql and notice driven not loaded driven not loaded.

                        artwawA Offline
                        artwawA Offline
                        artwaw
                        wrote on last edited by
                        #44

                        @juneleung AFAIR you need to manually deploy libpq.5.xx.dylib and relink your binary inside the .app to link to that - macdeployqt will not do it for you. I remember scripting that when I wrote a tool to interface with PostgreSQL. You'd need install-name-tool to do that.

                        For more information please re-read.

                        Kind Regards,
                        Artur

                        SGaistS 1 Reply Last reply
                        0
                        • artwawA artwaw

                          @juneleung AFAIR you need to manually deploy libpq.5.xx.dylib and relink your binary inside the .app to link to that - macdeployqt will not do it for you. I remember scripting that when I wrote a tool to interface with PostgreSQL. You'd need install-name-tool to do that.

                          SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #45

                          @artwaw not the binary, the plugin.

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

                          artwawA 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            @artwaw not the binary, the plugin.

                            artwawA Offline
                            artwawA Offline
                            artwaw
                            wrote on last edited by
                            #46

                            @SGaist You are right, of course, it's been a while since I dipped my fingers into this abyss.

                            At any rate, I dug out my script, it will require some polishing but the gist is:

                            #!/bin/zsh
                            cp -fR ~/cpp/build-appName-Desktop_Qt_5_15_2_clang_64bit-Release/appName.app .
                            macdeployqt appName.app -verbose=1 -always-overwrite
                            cp -f *.dylib appName.app/Contents/Frameworks/
                            install_name_tool -change /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib @executable_path/../Frameworks/libpq.5.dylib appName/Contents/PlugIns/sqldrivers/libqsqlpsql.dylib
                            install_name_tool -change libpq.5.dylib @executable_path/../Frameworks/libpq.5.dylib appName.app/Contents/MacOS/appName
                            

                            That works under assumption that you have all necessary Postgres files and your .app package in the same folder as the script. Or - at least - was working for the Qt 5.15.2.

                            I replaced my app name with appName.

                            For more information please re-read.

                            Kind Regards,
                            Artur

                            J 1 Reply Last reply
                            0
                            • artwawA artwaw

                              @SGaist You are right, of course, it's been a while since I dipped my fingers into this abyss.

                              At any rate, I dug out my script, it will require some polishing but the gist is:

                              #!/bin/zsh
                              cp -fR ~/cpp/build-appName-Desktop_Qt_5_15_2_clang_64bit-Release/appName.app .
                              macdeployqt appName.app -verbose=1 -always-overwrite
                              cp -f *.dylib appName.app/Contents/Frameworks/
                              install_name_tool -change /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib @executable_path/../Frameworks/libpq.5.dylib appName/Contents/PlugIns/sqldrivers/libqsqlpsql.dylib
                              install_name_tool -change libpq.5.dylib @executable_path/../Frameworks/libpq.5.dylib appName.app/Contents/MacOS/appName
                              

                              That works under assumption that you have all necessary Postgres files and your .app package in the same folder as the script. Or - at least - was working for the Qt 5.15.2.

                              I replaced my app name with appName.

                              J Offline
                              J Offline
                              juneleung
                              wrote on last edited by
                              #47

                              @artwaw Hi,
                              I dont have any Postgres files' *.dylib in my app dir and my app/Contents/Plugins/sqldrivers/ folder dont have libqsqlpsql.dylib, only libqsqlite.dylib libqsqlodbc.dylib and libqsqlpsql.dylib.
                              Where to make it create this dylib or where to copy it ? Which dylibs are postgresql needed?
                              Thanks!

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

                                libpq.5.dylib is provided through the PostgresApp.

                                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
                                • J juneleung

                                  @artwaw Hi,
                                  I dont have any Postgres files' *.dylib in my app dir and my app/Contents/Plugins/sqldrivers/ folder dont have libqsqlpsql.dylib, only libqsqlite.dylib libqsqlodbc.dylib and libqsqlpsql.dylib.
                                  Where to make it create this dylib or where to copy it ? Which dylibs are postgresql needed?
                                  Thanks!

                                  artwawA Offline
                                  artwawA Offline
                                  artwaw
                                  wrote on last edited by
                                  #49

                                  @juneleung Like @SGaist said. It is old and well know problem (I really thought addressed by now) that the plugin links to Postgres installation, somewhere in /Application/Postgres.app/[...]/libpq.5.dylib and in order to deploy the program properly one has to dabble and relink. I got annoyed and bored and semiautomated the deployment as above (I also wrote myself some script tools for signing and notarisation, because lack of integration is prevalent on macOS).

                                  Nonetheless - once you get hang on the particular quirks like this one, deploying on macOS is a relative breeze.

                                  For more information please re-read.

                                  Kind Regards,
                                  Artur

                                  J 1 Reply Last reply
                                  0
                                  • artwawA artwaw

                                    @juneleung Like @SGaist said. It is old and well know problem (I really thought addressed by now) that the plugin links to Postgres installation, somewhere in /Application/Postgres.app/[...]/libpq.5.dylib and in order to deploy the program properly one has to dabble and relink. I got annoyed and bored and semiautomated the deployment as above (I also wrote myself some script tools for signing and notarisation, because lack of integration is prevalent on macOS).

                                    Nonetheless - once you get hang on the particular quirks like this one, deploying on macOS is a relative breeze.

                                    J Offline
                                    J Offline
                                    juneleung
                                    wrote on last edited by
                                    #50

                                    @artwaw @SGaist

                                    Hi, I use these cmd :

                                    cp /Applications/Postgres.app/Contents/Versions/14/lib/libpq.5.14.dylib /Users/test/Build/build-test-Desktop_Qt_5_15_2_clang_64bit-Release/test.app/Contents/Frameworks/
                                    
                                    install_name_tool -change /Applications/Postgres.app/Contents/Versions/14/lib/libpq.5.dylib @executable_path/../Frameworks/libpq.5.14.dylib test/Contents/PlugIns/sqldrivers**/libqsqlpsql.dylib**
                                    
                                    install_name_tool -change libpq.5.dylib @executable_path/../Frameworks/libpq.5.14.dylib test.app/Contents/MacOS/test
                                    

                                    but an error with I don't have the libqsqlpsql.dylib in sqldrivers folder, and i can't found it in Applications/Postgres.app/Contents/Versions/14/lib/, where to find libqsqlpsql.dylib or how to make it generated automaticly by qt?

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

                                      Might be a silly question but are you using the SQL module in your test app ?

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

                                      J 1 Reply Last reply
                                      0
                                      • SGaistS SGaist

                                        Might be a silly question but are you using the SQL module in your test app ?

                                        J Offline
                                        J Offline
                                        juneleung
                                        wrote on last edited by juneleung
                                        #52

                                        @SGaist yes i have add sql in qt.

                                        QT += sql
                                        
                                        QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
                                        

                                        The release package installed in local Macbook can open and link to sqldatabase, but move to another mac will get wrong driver.

                                        Does I miss any steps when release packages?

                                        1 Reply Last reply
                                        0
                                        • J juneleung

                                          @artwaw @SGaist

                                          Hi, I use these cmd :

                                          cp /Applications/Postgres.app/Contents/Versions/14/lib/libpq.5.14.dylib /Users/test/Build/build-test-Desktop_Qt_5_15_2_clang_64bit-Release/test.app/Contents/Frameworks/
                                          
                                          install_name_tool -change /Applications/Postgres.app/Contents/Versions/14/lib/libpq.5.dylib @executable_path/../Frameworks/libpq.5.14.dylib test/Contents/PlugIns/sqldrivers**/libqsqlpsql.dylib**
                                          
                                          install_name_tool -change libpq.5.dylib @executable_path/../Frameworks/libpq.5.14.dylib test.app/Contents/MacOS/test
                                          

                                          but an error with I don't have the libqsqlpsql.dylib in sqldrivers folder, and i can't found it in Applications/Postgres.app/Contents/Versions/14/lib/, where to find libqsqlpsql.dylib or how to make it generated automaticly by qt?

                                          artwawA Offline
                                          artwawA Offline
                                          artwaw
                                          wrote on last edited by artwaw
                                          #53

                                          @juneleung said in MySQL driver detected but not loading on MacOS:

                                          I don't have the libqsqlpsql.dylib in sqldrivers folder, and i can't found it in Applications/Postgres.app/Contents/Versions/14/lib/, where to find libqsqlpsql.dylib or how to make it generated automaticly by qt?

                                          That what's macdeployqt should do, if memory serves. Important - can't my be with option App Store compatible. It is Qt plugin, should be deployed.

                                          For more information please re-read.

                                          Kind Regards,
                                          Artur

                                          J 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