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
QtWS25 Last Chance

QSqlDatabase: QPSQL driver not loaded

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 5 Posters 10.2k 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.
  • N Offline
    N Offline
    nkbartc
    wrote on last edited by nkbartc
    #1

    updated: this is what I got from QT_DEBUG_PLUGINS:

    "The plugin 'D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlodbcd.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
             not a plugin
    QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll"
    Found metadata in lib D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
                "QPSQL7",
                "QPSQL"
            ]
        },
        "archreq": 0,
        "className": "QPSQLDriverPlugin",
        "debug": false,
        "version": 331264
    }
    
    
    Got keys from plugin meta data ("QPSQL7", "QPSQL")
    QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll"
    Found metadata in lib D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll, metadata=
    {
        "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
        "MetaData": {
            "Keys": [
                "QPSQL7",
                "QPSQL"
            ]
        },
        "archreq": 1,
        "className": "QPSQLDriverPlugin",
        "debug": true,
        "version": 331264
    }
    
    
    "The plugin 'D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
             not a plugin
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/nkbar/Documents/build-myRPG_alpha-Desktop_Qt_5_14_0_MSVC2017_64bit-Release/Server/release/sqldrivers" ...
    Cannot load library D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers\qsqlpsql.dll: The specified module could not be found.
    QLibraryPrivate::loadPlugin failed on "D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll" : "Cannot load library D:\\Qt\\5.14.0\\msvc2017_64\\plugins\\sqldrivers\\qsqlpsql.dll: The specified module could not be found."
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.14.0/msvc2017_64/plugins/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/nkbar/Documents/build-myRPG_alpha-Desktop_Qt_5_14_0_MSVC2017_64bit-Release/Server/release/accessible" ...
    QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.14.0/msvc2017_64/plugins/accessiblebridge" ...
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/nkbar/Documents/build-myRPG_alpha-Desktop_Qt_5_14_0_MSVC2017_64bit-Release/Server/release/accessiblebridge" ...
    

    I checked "D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers\qsqlpsqld.dll" and I did found the dll which the debugger reports as missing. And I am also confused about why it complains about "'D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library.

    The kit I am using is msvc2017 64bit and the postgre I downloaded is also for 64bit.


    Errors:
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7

    OS: win10 64bit
    qt: 5.14.0
    kit: msvc2017 64bit
    PostgreSQL: 12.1

    Sqlite works well, but my project just can't work with PostgreSQL.

    I followed the official instruction: https://doc.qt.io/qt-5/sql-driver.html#qpsql

    Got no error but still couldn't connect to PostgreSQL. Same error messages saying that "QPSQL driver not loaded".

    I have also tried other solutions from here and stackoverflow and reinstall my qt 4 times, No luck still. I am really frustrated now and don't know what to do.

    the .pro:

    QT += core network gui widgets sql
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++11
    
    QTPLUGIN += QPSQL
    QT_DEBUG_PLUGINS=1
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    #INCLUDEPATH += "D:\psql\include"
    
    #LIBS += "D:\psql\lib\libpq.lib"
    
    
    SOURCES += \
        battle.cpp \
        creature.cpp \
        player.cpp \
        server.cpp \
        servermain.cpp \
        serverwindow.cpp \
        serverworker.cpp
    
    HEADERS += \
        battle.h \
        creature.h \
        data_structs.h \
        player.h \
        server.h \
        serverwindow.h \
        serverworker.h
    
    FORMS += \
        serverwindow.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    RESOURCES += \
        resource.qrc
    
    
    kshegunovK 1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @nkbartc said in QSqlDatabase: QPSQL driver not loaded:

      Cannot load library D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers\qsqlpsql.dll: The specified module could not be found.
      QLibraryPrivate::loadPlugin failed on "D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll" : "Cannot load library D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers\qsqlpsql.dll: The specified module could not be found."

      You're most likely missing libpq.dll in your PATH / in your folder of your executable.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      4
      • N Offline
        N Offline
        nkbartc
        wrote on last edited by
        #3

        2.png 1.png

        I already did that. I am showing the pictures just in case if I did it wrong.

        3 1 Reply Last reply
        1
        • N Offline
          N Offline
          nkbartc
          wrote on last edited by
          #4

          PostgreSQL12.1 is for 64bit. Could this cause the problem?

          aha_1980A 1 Reply Last reply
          0
          • N nkbartc

            PostgreSQL12.1 is for 64bit. Could this cause the problem?

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @nkbartc said in QSqlDatabase: QPSQL driver not loaded:

            PostgreSQL12.1 is for 64bit. Could this cause the problem?

            If your app is 32 bit, then yes.

            Regards

            Qt has to stay free or it will die.

            N 1 Reply Last reply
            1
            • aha_1980A aha_1980

              @nkbartc said in QSqlDatabase: QPSQL driver not loaded:

              PostgreSQL12.1 is for 64bit. Could this cause the problem?

              If your app is 32 bit, then yes.

              Regards

              N Offline
              N Offline
              nkbartc
              wrote on last edited by
              #6

              @aha_1980

              OS: win10 64bit
              qt: 5.14.0
              kit: msvc2017 64bit
              PostgreSQL: 12.1

              I think I am supposed to use PostgreSQL 64bit, but I just tried with PostgreSQL 32bit. No luck.....

              1 Reply Last reply
              0
              • Christian EhrlicherC Online
                Christian EhrlicherC Online
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Use dependency walker on qsqlpsql.dll to see what's missing. Maybe a msvcrt runtime

                Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                Visit the Qt Academy at https://academy.qt.io/catalog

                N 1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  Use dependency walker on qsqlpsql.dll to see what's missing. Maybe a msvcrt runtime

                  N Offline
                  N Offline
                  nkbartc
                  wrote on last edited by
                  #8

                  @Christian-Ehrlicher

                  I am using kit: msvc2017 64bit.

                  I suppose that I should run dependency walker on qsqlpsql.dll at
                  D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers ?

                  Thanks

                  1 Reply Last reply
                  0
                  • Christian EhrlicherC Online
                    Christian EhrlicherC Online
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @nkbartc said in QSqlDatabase: QPSQL driver not loaded:

                    I suppose that I should run dependency walker on qsqlpsql.dll at

                    yes

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      nkbartc
                      wrote on last edited by
                      #10

                      2.png

                      This is what I got

                      aha_1980A 1 Reply Last reply
                      0
                      • N nkbartc

                        2.png

                        This is what I got

                        aha_1980A Offline
                        aha_1980A Offline
                        aha_1980
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        @nkbartc press Ok, then minimize the tree on the left side, so that only one level of dependencies is visible.

                        The yellow warnings are harmless, AFAIK.

                        Qt has to stay free or it will die.

                        N 1 Reply Last reply
                        1
                        • Christian EhrlicherC Online
                          Christian EhrlicherC Online
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Please take a look at the direct dependencies

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          1 Reply Last reply
                          1
                          • aha_1980A aha_1980

                            @nkbartc press Ok, then minimize the tree on the left side, so that only one level of dependencies is visible.

                            The yellow warnings are harmless, AFAIK.

                            N Offline
                            N Offline
                            nkbartc
                            wrote on last edited by
                            #13

                            @aha_1980 @Christian-Ehrlicher

                            Like this? Sorry I am new to dependency walker.

                            1.png

                            aha_1980A 1 Reply Last reply
                            0
                            • N nkbartc

                              @aha_1980 @Christian-Ehrlicher

                              Like this? Sorry I am new to dependency walker.

                              1.png

                              aha_1980A Offline
                              aha_1980A Offline
                              aha_1980
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @nkbartc Yes, like that.

                              Unfortunately(?) that looks all good, so this library (qsqlpsql.dll) does not seem to be the problem.

                              Regards

                              Qt has to stay free or it will die.

                              1 Reply Last reply
                              0
                              • N nkbartc

                                updated: this is what I got from QT_DEBUG_PLUGINS:

                                "The plugin 'D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlodbcd.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
                                         not a plugin
                                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll"
                                Found metadata in lib D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll, metadata=
                                {
                                    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                                    "MetaData": {
                                        "Keys": [
                                            "QPSQL7",
                                            "QPSQL"
                                        ]
                                    },
                                    "archreq": 0,
                                    "className": "QPSQLDriverPlugin",
                                    "debug": false,
                                    "version": 331264
                                }
                                
                                
                                Got keys from plugin meta data ("QPSQL7", "QPSQL")
                                QFactoryLoader::QFactoryLoader() looking at "D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll"
                                Found metadata in lib D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll, metadata=
                                {
                                    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
                                    "MetaData": {
                                        "Keys": [
                                            "QPSQL7",
                                            "QPSQL"
                                        ]
                                    },
                                    "archreq": 1,
                                    "className": "QPSQLDriverPlugin",
                                    "debug": true,
                                    "version": 331264
                                }
                                
                                
                                "The plugin 'D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
                                         not a plugin
                                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/nkbar/Documents/build-myRPG_alpha-Desktop_Qt_5_14_0_MSVC2017_64bit-Release/Server/release/sqldrivers" ...
                                Cannot load library D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers\qsqlpsql.dll: The specified module could not be found.
                                QLibraryPrivate::loadPlugin failed on "D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll" : "Cannot load library D:\\Qt\\5.14.0\\msvc2017_64\\plugins\\sqldrivers\\qsqlpsql.dll: The specified module could not be found."
                                QSqlDatabase: QPSQL driver not loaded
                                QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
                                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.14.0/msvc2017_64/plugins/accessible" ...
                                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/nkbar/Documents/build-myRPG_alpha-Desktop_Qt_5_14_0_MSVC2017_64bit-Release/Server/release/accessible" ...
                                QFactoryLoader::QFactoryLoader() checking directory path "D:/Qt/5.14.0/msvc2017_64/plugins/accessiblebridge" ...
                                QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/nkbar/Documents/build-myRPG_alpha-Desktop_Qt_5_14_0_MSVC2017_64bit-Release/Server/release/accessiblebridge" ...
                                

                                I checked "D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers\qsqlpsqld.dll" and I did found the dll which the debugger reports as missing. And I am also confused about why it complains about "'D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library.

                                The kit I am using is msvc2017 64bit and the postgre I downloaded is also for 64bit.


                                Errors:
                                QSqlDatabase: QPSQL driver not loaded
                                QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7

                                OS: win10 64bit
                                qt: 5.14.0
                                kit: msvc2017 64bit
                                PostgreSQL: 12.1

                                Sqlite works well, but my project just can't work with PostgreSQL.

                                I followed the official instruction: https://doc.qt.io/qt-5/sql-driver.html#qpsql

                                Got no error but still couldn't connect to PostgreSQL. Same error messages saying that "QPSQL driver not loaded".

                                I have also tried other solutions from here and stackoverflow and reinstall my qt 4 times, No luck still. I am really frustrated now and don't know what to do.

                                the .pro:

                                QT += core network gui widgets sql
                                
                                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                                
                                CONFIG += c++11
                                
                                QTPLUGIN += QPSQL
                                QT_DEBUG_PLUGINS=1
                                
                                # The following define makes your compiler emit warnings if you use
                                # any Qt feature that has been marked deprecated (the exact warnings
                                # depend on your compiler). Please consult the documentation of the
                                # deprecated API in order to know how to port your code away from it.
                                DEFINES += QT_DEPRECATED_WARNINGS
                                
                                # You can also make your code fail to compile if it uses deprecated APIs.
                                # In order to do so, uncomment the following line.
                                # You can also select to disable deprecated APIs only up to a certain version of Qt.
                                #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                                
                                #INCLUDEPATH += "D:\psql\include"
                                
                                #LIBS += "D:\psql\lib\libpq.lib"
                                
                                
                                SOURCES += \
                                    battle.cpp \
                                    creature.cpp \
                                    player.cpp \
                                    server.cpp \
                                    servermain.cpp \
                                    serverwindow.cpp \
                                    serverworker.cpp
                                
                                HEADERS += \
                                    battle.h \
                                    creature.h \
                                    data_structs.h \
                                    player.h \
                                    server.h \
                                    serverwindow.h \
                                    serverworker.h
                                
                                FORMS += \
                                    serverwindow.ui
                                
                                # Default rules for deployment.
                                qnx: target.path = /tmp/$${TARGET}/bin
                                else: unix:!android: target.path = /opt/$${TARGET}/bin
                                !isEmpty(target.path): INSTALLS += target
                                
                                RESOURCES += \
                                    resource.qrc
                                
                                
                                kshegunovK Offline
                                kshegunovK Offline
                                kshegunov
                                Moderators
                                wrote on last edited by
                                #15

                                @nkbartc said in QSqlDatabase: QPSQL driver not loaded:

                                I checked "D:\Qt\5.14.0\msvc2017_64\plugins\sqldrivers\qsqlpsqld.dll" and I did found the dll which the debugger reports as missing. And I am also confused about why it complains about "'D:/Qt/5.14.0/msvc2017_64/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library.

                                On windows debug and release libraries are different binaries and can't be loaded interchangeably (unlike with linux). You probably need to build the driver with debug.

                                Read and abide by the Qt Code of Conduct

                                1 Reply Last reply
                                1
                                • N nkbartc

                                  2.png 1.png

                                  I already did that. I am showing the pictures just in case if I did it wrong.

                                  3 Offline
                                  3 Offline
                                  3KKK
                                  wrote on last edited by
                                  #16

                                  @nkbartc Pointing to the dll in the bin library solved the issue for me. Change the path from D:\psql\lib to D:\psql\bin

                                  1 Reply Last reply
                                  1

                                  • Login

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