Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Installing Qt with PostgreSQL drivers macOS m1
Forum Updated to NodeBB v4.3 + New Features

Installing Qt with PostgreSQL drivers macOS m1

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
6 Posts 3 Posters 1.6k 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.
  • K Offline
    K Offline
    kaptsea
    wrote on 6 Jun 2021, 18:47 last edited by
    #1

    Hello all

    I am trying to install Qt with PostgreSQL sql driver, and have tried almost everything to have the psql drivers before installing Qt.

    I have tried installing Postgres via homebrew, via the official installer and the Postgres.app and libpq, libpqxx via homebrew but neither the offline or online installer detects Postgres.

    Has anyone managed to do this?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Jun 2021, 18:57 last edited by
      #2

      Hi and welcome to devnet,

      Start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show you a dump of what happens when the plugins are getting loaded and why it failed.

      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
      • K Offline
        K Offline
        kaptsea
        wrote on 7 Jun 2021, 07:27 last edited by
        #3

        @SGaist said in Installing Qt with PostgreSQL drivers macOS m1:

        QT_DEBUG_PLUGINS

        Thank you so much for your reply.

        Unfortunately I am not really familiar with the output.

        QFactoryLoader::QFactoryLoader() checking directory path "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers" ...
        QFactoryLoader::QFactoryLoader() looking at "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlite.dylib"
        Found metadata in lib /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlite.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QSQLITE"
                ]
            },
            "archreq": 0,
            "className": "QSQLiteDriverPlugin",
            "debug": false,
            "version": 331520
        }
        
        
        Got keys from plugin meta data ("QSQLITE")
        QFactoryLoader::QFactoryLoader() looking at "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlodbc.dylib"
        Found metadata in lib /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QODBC3",
                    "QODBC"
                ]
            },
            "archreq": 0,
            "className": "QODBCDriverPlugin",
            "debug": false,
            "version": 331520
        }
        
        
        Got keys from plugin meta data ("QODBC3", "QODBC")
        QFactoryLoader::QFactoryLoader() looking at "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib"
        Found metadata in lib /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QPSQL7",
                    "QPSQL"
                ]
            },
            "archreq": 0,
            "className": "QPSQLDriverPlugin",
            "debug": false,
            "version": 331520
        }
        
        
        Got keys from plugin meta data ("QPSQL7", "QPSQL")
        QFactoryLoader::QFactoryLoader() checking directory path "/Users/USERNAME/src/audioManager/cmake-build-debug/sqldrivers" ...
        Cannot load library /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib: (dlopen(/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, 133): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib
          Referenced from: /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib
          Reason: image not found)
        QLibraryPrivate::loadPlugin failed on "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib" : "Cannot load library /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib: (dlopen(/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, 133): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib\n  Referenced from: /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib\n  Reason: image not found)"
        QSqlDatabase: QPSQL driver not loaded
        QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
        "Driver not loaded Driver not loaded"
        

        From what I collect, it says it cannot find the driver and it cannot find the driver because when I installed qt, even though I had installed Postgres and qt-postgres (from brew), it could not find the dev libs. Does that make sense?

        A 1 Reply Last reply 15 Mar 2023, 00:59
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Jun 2021, 11:12 last edited by
          #4

          The PSQL driver is found that is not the issue.

          What happens here is that the driver has been built using libpq coming with the Postgres App which is the official package provided by the project to get a quick and easy installation of PostgreSQL on macOS.

          See this path

          @kaptsea said in Installing Qt with PostgreSQL drivers macOS m1:

          /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib

          Where did brew install PostgreSQL ?
          Can you locate the libpq library in there ?
          If you find it, then what you can do is use install_name_tool to update that path to match the one from the libpq dylib you have on your machine.

          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
          • K kaptsea
            7 Jun 2021, 07:27

            @SGaist said in Installing Qt with PostgreSQL drivers macOS m1:

            QT_DEBUG_PLUGINS

            Thank you so much for your reply.

            Unfortunately I am not really familiar with the output.

            QFactoryLoader::QFactoryLoader() checking directory path "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers" ...
            QFactoryLoader::QFactoryLoader() looking at "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlite.dylib"
            Found metadata in lib /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlite.dylib, metadata=
            {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "QSQLITE"
                    ]
                },
                "archreq": 0,
                "className": "QSQLiteDriverPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("QSQLITE")
            QFactoryLoader::QFactoryLoader() looking at "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlodbc.dylib"
            Found metadata in lib /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlodbc.dylib, metadata=
            {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "QODBC3",
                        "QODBC"
                    ]
                },
                "archreq": 0,
                "className": "QODBCDriverPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("QODBC3", "QODBC")
            QFactoryLoader::QFactoryLoader() looking at "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib"
            Found metadata in lib /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, metadata=
            {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                    "Keys": [
                        "QPSQL7",
                        "QPSQL"
                    ]
                },
                "archreq": 0,
                "className": "QPSQLDriverPlugin",
                "debug": false,
                "version": 331520
            }
            
            
            Got keys from plugin meta data ("QPSQL7", "QPSQL")
            QFactoryLoader::QFactoryLoader() checking directory path "/Users/USERNAME/src/audioManager/cmake-build-debug/sqldrivers" ...
            Cannot load library /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib: (dlopen(/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, 133): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib
              Referenced from: /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib
              Reason: image not found)
            QLibraryPrivate::loadPlugin failed on "/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib" : "Cannot load library /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib: (dlopen(/Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib, 133): Library not loaded: /Applications/Postgres.app/Contents/Versions/9.6/lib/libpq.5.dylib\n  Referenced from: /Users/USERNAME/Qt/5.15.2/clang_64/plugins/sqldrivers/libqsqlpsql.dylib\n  Reason: image not found)"
            QSqlDatabase: QPSQL driver not loaded
            QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
            "Driver not loaded Driver not loaded"
            

            From what I collect, it says it cannot find the driver and it cannot find the driver because when I installed qt, even though I had installed Postgres and qt-postgres (from brew), it could not find the dev libs. Does that make sense?

            A Offline
            A Offline
            Albert M.
            wrote on 15 Mar 2023, 00:59 last edited by
            #5

            @kaptsea @SGaist -

            I hope this message finds you well. I'm reaching out to you because I've been having some trouble with setting up a PostgreSQL database connection on my Apple Silicon M2 machine.

            Specifically, I keep getting the error message "QSqlDatabase: QPSQL driver not loaded" when attempting to establish a connection using the Qt SQL module.

            I've read almost every thread and post on this topic, but unfortunately, I haven't been able to find a solution that works for me. I'm starting to feel a bit stuck, and I was hoping that you might have some experience or insight that could help me resolve this issue.

            I am using install_name_tool to update the path should help resolve the issue. Just to confirm, you would need to run the following command in your terminal, replacing the path with the location of your libpq dylib:

            1. POSTGRES@15 installed using Homebrew

            ➜  lib otool -L libpq.5.dylib
            
            libpq.5.dylib:
            	/usr/local/opt/postgresql@15/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.15.0)
            	/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 12.0.0, current version 12.0.0)
            	/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
            	/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
            	/usr/local/opt/krb5/lib/libgssapi_krb5.2.2.dylib (compatibility version 2.0.0, current version 2.2.0)
            	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
            	/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
            
            1. POSTGRES.APP
            ➜ lib otool -L libpq.5.dylib
            
            libpq.5.dylib (architecture x86_64):
            	/Applications/Postgres.app/Contents/Versions/15/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.15.0)
            	@loader_path/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
            	@loader_path/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
            	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
            libpq.5.dylib (architecture arm64):
            	/Applications/Postgres.app/Contents/Versions/15/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.15.0)
            	@loader_path/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
            	@loader_path/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
            	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)```
            
            3. install_name_tool command
            

            install_name_tool -change /usr/local/opt/postgresql@15/lib/libpq.5.dylib /Applications/Postgres.app/Contents/Versions/15/lib/libpq.5.dylib libpq.5.dylib

            
             The issue still after I ran the command "QSqlDatabase: QPSQL driver not loaded"
            
            can you please help?
            S 1 Reply Last reply 15 Mar 2023, 20:53
            0
            • A Albert M.
              15 Mar 2023, 00:59

              @kaptsea @SGaist -

              I hope this message finds you well. I'm reaching out to you because I've been having some trouble with setting up a PostgreSQL database connection on my Apple Silicon M2 machine.

              Specifically, I keep getting the error message "QSqlDatabase: QPSQL driver not loaded" when attempting to establish a connection using the Qt SQL module.

              I've read almost every thread and post on this topic, but unfortunately, I haven't been able to find a solution that works for me. I'm starting to feel a bit stuck, and I was hoping that you might have some experience or insight that could help me resolve this issue.

              I am using install_name_tool to update the path should help resolve the issue. Just to confirm, you would need to run the following command in your terminal, replacing the path with the location of your libpq dylib:

              1. POSTGRES@15 installed using Homebrew

              ➜  lib otool -L libpq.5.dylib
              
              libpq.5.dylib:
              	/usr/local/opt/postgresql@15/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.15.0)
              	/usr/local/opt/gettext/lib/libintl.8.dylib (compatibility version 12.0.0, current version 12.0.0)
              	/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
              	/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
              	/usr/local/opt/krb5/lib/libgssapi_krb5.2.2.dylib (compatibility version 2.0.0, current version 2.2.0)
              	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0)
              	/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
              
              1. POSTGRES.APP
              ➜ lib otool -L libpq.5.dylib
              
              libpq.5.dylib (architecture x86_64):
              	/Applications/Postgres.app/Contents/Versions/15/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.15.0)
              	@loader_path/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
              	@loader_path/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
              	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)
              libpq.5.dylib (architecture arm64):
              	/Applications/Postgres.app/Contents/Versions/15/lib/libpq.5.dylib (compatibility version 5.0.0, current version 5.15.0)
              	@loader_path/libssl.3.dylib (compatibility version 3.0.0, current version 3.0.0)
              	@loader_path/libcrypto.3.dylib (compatibility version 3.0.0, current version 3.0.0)
              	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)```
              
              3. install_name_tool command
              

              install_name_tool -change /usr/local/opt/postgresql@15/lib/libpq.5.dylib /Applications/Postgres.app/Contents/Versions/15/lib/libpq.5.dylib libpq.5.dylib

              
               The issue still after I ran the command "QSqlDatabase: QPSQL driver not loaded"
              
              can you please help?
              S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 15 Mar 2023, 20:53 last edited by
              #6

              @Albert-M hi, why are you changing the path of the PostgreSQL library ? You should update the one from the Qt plugin.

              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

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved