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. QSqlDatabase:QPSQL Driver not loaded Driver not loaded
Qt 6.11 is out! See what's new in the release blog

QSqlDatabase:QPSQL Driver not loaded Driver not loaded

Scheduled Pinned Locked Moved Solved General and Desktop
26 Posts 5 Posters 10.4k 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.
  • R Offline
    R Offline
    ram070787
    wrote on last edited by
    #1

    This question has been asked many times as I have seen many posts on this. But nothing seems to be working for me. I am running a Qt version 5.5.1 with QMake version 3.0 in Ubuntu 16.04. It is causing a runtime error as

    QSqlDatabase: unknown driver not loaded

    QSqlDatabase: available drivers: QSQLITE QPSQL QPSQL7

    "\uFFFF:Driver not loaded Driver not loaded"

    As the above available drivers I have my .so files at the "sqldriver" folder in Qt plugins folder. ldd on my executable and also on the library files are fine and dependencies are found. I am using a Postgresql 9.5 and I have tried to pass in the \bin and \lib paths of the Postgresql to Qt through Run Environment variables. Setting my QT_DEBUG_PLUGINS=1 gave

    Debug: 14.05.2018 09:51:55.831 QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
    Debug: 14.05.2018 09:51:55.831 QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
    Warning: 14.05.2018 09:51:55.831 Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QSQLITE"
    ]
    },
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 328961
    }

    Debug: 14.05.2018 09:51:55.831 Got keys from plugin meta data ("QSQLITE")
    Debug: 14.05.2018 09:51:55.831 QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlpsql.so"
    Warning: 14.05.2018 09:51:55.831 Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlpsql.so, metadata=
    {
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
    "Keys": [
    "QPSQL7",
    "QPSQL"
    ]
    },
    "className": "QPSQLDriverPlugin",
    "debug": false,
    "version": 328961
    }

    which looks fine. Anyone with an idea of what maybe wrong? Thanks

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      I suspect that some dependency library of libqsqlpsql.so missing. OR it could be issue of version mismatch between what qt is expecting and what is available in the system.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ram070787
        wrote on last edited by
        #3

        A ldd on the libqsqlpsql.so library shows all dependencies are found. The QT_DEBUG_PLUGINS shows the version as

        "className": "QPSQLDriverPlugin",
        "debug": false,
        "version": 328961

        This same version with Qmake version 3.0 and Qt version 5.5.1 is running in another computer. A link is established with the Database but not for me. What can I check with his computer and mine?

        1 Reply Last reply
        0
        • R Offline
          R Offline
          ram070787
          wrote on last edited by ram070787
          #4

          Also QT_DEBUG_PLUGINS = 1 gave an output that the driver .so files are being looked at the directory my binary file is generated. So I even created a directory named "sqldriver" in the directory "\bin" and moved by library files but didnt work.

          jsulmJ 1 Reply Last reply
          0
          • R ram070787

            Also QT_DEBUG_PLUGINS = 1 gave an output that the driver .so files are being looked at the directory my binary file is generated. So I even created a directory named "sqldriver" in the directory "\bin" and moved by library files but didnt work.

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

            @ram070787 Is it all you get if you set QT_DEBUG_PLUGINS=1 ?

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

            R 1 Reply Last reply
            0
            • jsulmJ jsulm

              @ram070787 Is it all you get if you set QT_DEBUG_PLUGINS=1 ?

              R Offline
              R Offline
              ram070787
              wrote on last edited by ram070787
              #6

              @jsulm Yes !
              Debug: 14.05.2018 13:24:49.864 Application startUp
              Loc: [../../controlsystem/mycontrol/mycontrol.cpp:1452]
              Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
              Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
              Warning: 14.05.2018 13:24:49.864 Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
              {
              "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
              "MetaData": {
              "Keys": [
              "QSQLITE"
              ]
              },
              "className": "QSQLiteDriverPlugin",
              "debug": false,
              "version": 328961
              }

              Debug: 14.05.2018 13:24:49.864 Got keys from plugin meta data ("QSQLITE")
              Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlpsql.so"
              Warning: 14.05.2018 13:24:49.864 Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlpsql.so, metadata=
              {
              "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
              "MetaData": {
              "Keys": [
              "QPSQL7",
              "QPSQL"
              ]
              },
              "className": "QPSQLDriverPlugin",
              "debug": false,
              "version": 328961
              }

              Debug: 14.05.2018 13:24:49.864 Got keys from plugin meta data ("QPSQL7", "QPSQL")
              Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() checking directory path "/home/workspacetest/branches/user/build-controlsystem-Desktop-Debug/mycontrol/sqldrivers" ...
              Warning: 14.05.2018 13:24:49.864 QSqlDatabase: unknown driver not loaded
              Warning: 14.05.2018 13:24:49.864 QSqlDatabase: available drivers: QSQLITE QPSQL QPSQL7
              Critical: 14.05.2018 13:24:49.864 PtsSystem: Not able to access database. "\uFFFF:Driver not loaded Driver not loaded"
              Loc: [../../controlsystem/mycontrol/mycontrol.cpp:1452]
              Fatal: 14.05.2018 13:24:49.864 Caught exception: ￿:Driver not loaded Driver not loaded.

              This is the complete output

              jsulmJ 1 Reply Last reply
              0
              • R ram070787

                @jsulm Yes !
                Debug: 14.05.2018 13:24:49.864 Application startUp
                Loc: [../../controlsystem/mycontrol/mycontrol.cpp:1452]
                Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers" ...
                Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so"
                Warning: 14.05.2018 13:24:49.864 Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlite.so, metadata=
                {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                "Keys": [
                "QSQLITE"
                ]
                },
                "className": "QSQLiteDriverPlugin",
                "debug": false,
                "version": 328961
                }

                Debug: 14.05.2018 13:24:49.864 Got keys from plugin meta data ("QSQLITE")
                Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() looking at "/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlpsql.so"
                Warning: 14.05.2018 13:24:49.864 Found metadata in lib /usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers/libqsqlpsql.so, metadata=
                {
                "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                "MetaData": {
                "Keys": [
                "QPSQL7",
                "QPSQL"
                ]
                },
                "className": "QPSQLDriverPlugin",
                "debug": false,
                "version": 328961
                }

                Debug: 14.05.2018 13:24:49.864 Got keys from plugin meta data ("QPSQL7", "QPSQL")
                Debug: 14.05.2018 13:24:49.864 QFactoryLoader::QFactoryLoader() checking directory path "/home/workspacetest/branches/user/build-controlsystem-Desktop-Debug/mycontrol/sqldrivers" ...
                Warning: 14.05.2018 13:24:49.864 QSqlDatabase: unknown driver not loaded
                Warning: 14.05.2018 13:24:49.864 QSqlDatabase: available drivers: QSQLITE QPSQL QPSQL7
                Critical: 14.05.2018 13:24:49.864 PtsSystem: Not able to access database. "\uFFFF:Driver not loaded Driver not loaded"
                Loc: [../../controlsystem/mycontrol/mycontrol.cpp:1452]
                Fatal: 14.05.2018 13:24:49.864 Caught exception: ￿:Driver not loaded Driver not loaded.

                This is the complete output

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

                @ram070787 My guess is that PostgreSQL client library is missing. ldd will not help here as Qt uses dlopen() to load it, it does not link against it.

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

                R 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @ram070787 My guess is that PostgreSQL client library is missing. ldd will not help here as Qt uses dlopen() to load it, it does not link against it.

                  R Offline
                  R Offline
                  ram070787
                  wrote on last edited by
                  #8

                  @jsulm Will "sudo apt-get install postgresql-client" install client libraries to my computer for Postgresql? If yes I have already installed these files in my computer.

                  jsulmJ 1 Reply Last reply
                  0
                  • R ram070787

                    @jsulm Will "sudo apt-get install postgresql-client" install client libraries to my computer for Postgresql? If yes I have already installed these files in my computer.

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

                    @ram070787 I don't know how Debian/Ubuntu packages this stuff. You can search for them on your system, not sure which one is used by Qt (the C or C++ one, see https://wiki.postgresql.org/wiki/Client_Libraries).

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

                    R 1 Reply Last reply
                    0
                    • jsulmJ jsulm

                      @ram070787 I don't know how Debian/Ubuntu packages this stuff. You can search for them on your system, not sure which one is used by Qt (the C or C++ one, see https://wiki.postgresql.org/wiki/Client_Libraries).

                      R Offline
                      R Offline
                      ram070787
                      wrote on last edited by
                      #10

                      @jsulm I checked with another computer for the installed libraries regarding Postgresql. We both have same libraries installed (libpq5.so and other Postgresql librraies. ) It works will with him but not with me. And i think libpqxx packages are used by C++, so it may be used by Qt also.

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

                        Hi and welcome to devnet,

                        Did you install PostgreSQL development packages for your distribution ?

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

                        R 2 Replies Last reply
                        1
                        • SGaistS SGaist

                          Hi and welcome to devnet,

                          Did you install PostgreSQL development packages for your distribution ?

                          R Offline
                          R Offline
                          ram070787
                          wrote on last edited by
                          #12

                          @SGaist Yes I have installed "postgresql-dev" on my computer. Also this error below..
                          QSqlDatabase: unknown driver not loaded

                          QSqlDatabase: available drivers: QSQLITE QPSQL QPSQL7

                          "\uFFFF:Driver not loaded Driver not loaded"

                          I was able to recreate this error in another machine when I removed libqsqlpsql.so from the sqldriver folder in the Qt installtion and the error looked like

                          QSqlDatabase: QPSQL driver not loaded

                          QSqlDatabase: available drivers: QSQLITE QPSQL QPSQL7

                          "\uFFFF:Driver not loaded Driver not loaded"

                          I can understand this error. But mine shows "unknown".

                          1 Reply Last reply
                          0
                          • R Offline
                            R Offline
                            ram070787
                            wrote on last edited by ram070787
                            #13

                            I am working on codes written by other persons and have no idea how they did this . It seems to me that QSqldatabase is looking for "unknown driver" and is not able to load it. Is there any reason that this can happen?

                            1 Reply Last reply
                            0
                            • SGaistS SGaist

                              Hi and welcome to devnet,

                              Did you install PostgreSQL development packages for your distribution ?

                              R Offline
                              R Offline
                              ram070787
                              wrote on last edited by ram070787
                              #14

                              @SGaist These are my postgres packages installed

                              1. postgresql/xenial-updates,xenial-updates,xenial-security,xenial- security,now 9.5+173ubuntu0.1 all [installed]
                              2. postgresql-9.5/xenial-updates,xenial-security,now 9.5.12-0ubuntu0.16.04 amd64 [installed,automatic]
                              3. postgresql-client-9.5/xenial-updates,xenial-security,now 9.5.12-0ubuntu0.16.04 amd64 [installed]
                              4. postgresql-client-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 173ubuntu0.1 all [installed]
                              5. postgresql-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 173ubuntu0.1 all [installed,automatic]
                              6. postgresql-contrib-9.5/xenial-updates,xenial-security,now 9.5.12-0ubuntu0.16.04 amd64 [installed,automatic]

                              I also have installed libpq5 and libpq-dev on my computer.

                              jsulmJ 1 Reply Last reply
                              0
                              • R ram070787

                                @SGaist These are my postgres packages installed

                                1. postgresql/xenial-updates,xenial-updates,xenial-security,xenial- security,now 9.5+173ubuntu0.1 all [installed]
                                2. postgresql-9.5/xenial-updates,xenial-security,now 9.5.12-0ubuntu0.16.04 amd64 [installed,automatic]
                                3. postgresql-client-9.5/xenial-updates,xenial-security,now 9.5.12-0ubuntu0.16.04 amd64 [installed]
                                4. postgresql-client-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 173ubuntu0.1 all [installed]
                                5. postgresql-common/xenial-updates,xenial-updates,xenial-security,xenial-security,now 173ubuntu0.1 all [installed,automatic]
                                6. postgresql-contrib-9.5/xenial-updates,xenial-security,now 9.5.12-0ubuntu0.16.04 amd64 [installed,automatic]

                                I also have installed libpq5 and libpq-dev on my computer.

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

                                @ram070787 What about libpqxx-dev ?

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

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

                                  There's something mighty fishy here.

                                  Did you install of Qt's development packages from your distribution ?
                                  What do you get if you run ldd on the PostgreSQL plugin ?

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

                                  R 1 Reply Last reply
                                  0
                                  • SGaistS SGaist

                                    There's something mighty fishy here.

                                    Did you install of Qt's development packages from your distribution ?
                                    What do you get if you run ldd on the PostgreSQL plugin ?

                                    R Offline
                                    R Offline
                                    ram070787
                                    wrote on last edited by
                                    #17

                                    @SGaist If I am right by Qt development package you mean the qtdeclarative5-dev packages. I had those installed.

                                    I did not understand where this PostgreSQL plugin is? A "ldd psql" had all the dependencies.

                                    1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @ram070787 What about libpqxx-dev ?

                                      R Offline
                                      R Offline
                                      ram070787
                                      wrote on last edited by
                                      #18

                                      @jsulm Yeah those were installed.

                                      1 Reply Last reply
                                      0
                                      • R Offline
                                        R Offline
                                        ram070787
                                        wrote on last edited by
                                        #19

                                        I already spent a week trying to find the error and unsuccessful. so I have reinstalled my complete system. I will try to install all essential libraries and softwares and will come back here again. Thanks everyone for your help.

                                        1 Reply Last reply
                                        0
                                        • R Offline
                                          R Offline
                                          ram070787
                                          wrote on last edited by ram070787
                                          #20

                                          Hi guys. I have found the reason for this. But not sure what to do about this. Maybe you guys are experienced in this.

                                          My application runs by reading an .ini file in the folder "etc/myfile.ini" and automatically generates the same myfile.ini in my home folder with some details about my login credentials to the application that is built by Qt. The first run in my Qt opens my application and an .ini file is generated in my home folder. When I stop my application and restart it is gives "unknown driver error". So this .ini file is not generated again afresh. I have to delete the old .ini file in my home folder before running my application again.

                                          Also my application gets a connection with the Sql database and the details about the database are written in the .ini file generated in my home folder. These details are written in another computer and not in mine.

                                          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