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. QSqlDatabase: QPSQL driver not loaded once again!
Forum Updated to NodeBB v4.3 + New Features

QSqlDatabase: QPSQL driver not loaded once again!

Scheduled Pinned Locked Moved Solved Installation and Deployment
qpsqlqsqlpostgresqldeploydeploying
18 Posts 3 Posters 14.1k 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.
  • M mbnoimi

    Whenever I want to deploy my app I get this error message:

    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
    "Driver not loaded Driver not loaded"
    

    Although I followed all Qt deployment steps!

    • OS: Windows 7 x64
    • Qt: 5.7
    • Postgres: 9.3.4-4-windows-x64

    See files structure please:

    bin/
    ├── audio
    │   ├── qtaudio_windowsd.dll
    │   └── qtaudio_windows.dll
    ├── bearer
    │   ├── qgenericbearerd.dll
    │   ├── qgenericbearer.dll
    │   ├── qnativewifibearerd.dll
    │   └── qnativewifibearer.dll
    ├── canbus
    │   ├── qtpeakcanbusd.dll
    │   ├── qtpeakcanbus.dll
    │   ├── qttinycanbusd.dll
    │   └── qttinycanbus.dll
    ├── designer
    │   ├── qaxwidget.dll
    │   └── qquickwidget.dll
    ├── gamepads
    │   ├── xinputgamepadd.dll
    │   └── xinputgamepad.dll
    ├── generic
    │   ├── qtuiotouchplugind.dll
    │   └── qtuiotouchplugin.dll
    ├── geoservices
    │   ├── qtgeoservices_mapboxd.dll
    │   ├── qtgeoservices_mapbox.dll
    │   ├── qtgeoservices_nokiad.dll
    │   ├── qtgeoservices_nokia.dll
    │   ├── qtgeoservices_osmd.dll
    │   └── qtgeoservices_osm.dll
    ├── iconengines
    │   ├── qsvgicond.dll
    │   └── qsvgicon.dll
    ├── iconv.dll
    ├── imageformats
    │   ├── qddsd.dll
    │   ├── qdds.dll
    │   ├── qgifd.dll
    │   ├── qgif.dll
    │   ├── qicnsd.dll
    │   ├── qicns.dll
    │   ├── qicod.dll
    │   ├── qico.dll
    │   ├── qjpegd.dll
    │   ├── qjpeg.dll
    │   ├── qsvgd.dll
    │   ├── qsvg.dll
    │   ├── qtgad.dll
    │   ├── qtga.dll
    │   ├── qtiffd.dll
    │   ├── qtiff.dll
    │   ├── qwbmpd.dll
    │   ├── qwbmp.dll
    │   ├── qwebpd.dll
    │   └── qwebp.dll
    ├── libeay32.dll
    ├── libEGLd.dll
    ├── libEGL.dll
    ├── libgcc_s_dw2-1.dll
    ├── libGLESv2d.dll
    ├── libGLESv2.dll
    ├── libintl-8.dll
    ├── libpq.dll
    ├── libstdc++-6.dll
    ├── libwinpthread-1.dll
    ├── libxml2.dll
    ├── libxslt.dll
    ├── mediaservice
    │   ├── dsengined.dll
    │   ├── dsengine.dll
    │   ├── qtmedia_audioengined.dll
    │   └── qtmedia_audioengine.dll
    ├── opengl32sw.dll
    ├── platforminputcontexts
    │   ├── qtvirtualkeyboardplugind.dll
    │   └── qtvirtualkeyboardplugin.dll
    ├── platforms
    │   ├── qminimald.dll
    │   ├── qminimal.dll
    │   ├── qoffscreend.dll
    │   ├── qoffscreen.dll
    │   ├── qwindowsd.dll
    │   └── qwindows.dll
    ├── playlistformats
    │   ├── qtmultimedia_m3ud.dll
    │   └── qtmultimedia_m3u.dll
    ├── position
    │   ├── qtposition_geoclued.dll
    │   ├── qtposition_geoclue.dll
    │   ├── qtposition_positionpolld.dll
    │   ├── qtposition_positionpoll.dll
    │   ├── qtposition_serialnmead.dll
    │   └── qtposition_serialnmea.dll
    ├── printsupport
    │   ├── windowsprintersupportd.dll
    │   └── windowsprintersupport.dll
    ├── qmltooling
    │   ├── qmldbg_debuggerd.dll
    │   ├── qmldbg_debugger.dll
    │   ├── qmldbg_inspectord.dll
    │   ├── qmldbg_inspector.dll
    │   ├── qmldbg_locald.dll
    │   ├── qmldbg_local.dll
    │   ├── qmldbg_natived.dll
    │   ├── qmldbg_native.dll
    │   ├── qmldbg_profilerd.dll
    │   ├── qmldbg_profiler.dll
    │   ├── qmldbg_quickprofilerd.dll
    │   ├── qmldbg_quickprofiler.dll
    │   ├── qmldbg_serverd.dll
    │   ├── qmldbg_server.dll
    │   ├── qmldbg_tcpd.dll
    │   └── qmldbg_tcp.dll
    ├── Qt53DCored.dll
    ├── Qt53DCore.dll
    ├── Qt53DExtrasd.dll
    ├── Qt53DExtras.dll
    ├── Qt53DInputd.dll
    ├── Qt53DInput.dll
    ├── Qt53DLogicd.dll
    ├── Qt53DLogic.dll
    ├── Qt53DQuickd.dll
    ├── Qt53DQuick.dll
    ├── Qt53DQuickExtrasd.dll
    ├── Qt53DQuickExtras.dll
    ├── Qt53DQuickInputd.dll
    ├── Qt53DQuickInput.dll
    ├── Qt53DQuickRenderd.dll
    ├── Qt53DQuickRender.dll
    ├── Qt53DRenderd.dll
    ├── Qt53DRender.dll
    ├── Qt5Bluetoothd.dll
    ├── Qt5Bluetooth.dll
    ├── Qt5Chartsd.dll
    ├── Qt5Charts.dll
    ├── Qt5CLucened.dll
    ├── Qt5CLucene.dll
    ├── Qt5Concurrentd.dll
    ├── Qt5Concurrent.dll
    ├── Qt5Cored.dll
    ├── Qt5Core.dll
    ├── Qt5DataVisualizationd.dll
    ├── Qt5DataVisualization.dll
    ├── Qt5DBusd.dll
    ├── Qt5DBus.dll
    ├── Qt5DesignerComponentsd.dll
    ├── Qt5DesignerComponents.dll
    ├── Qt5Designerd.dll
    ├── Qt5Designer.dll
    ├── Qt5Gamepadd.dll
    ├── Qt5Gamepad.dll
    ├── Qt5Guid.dll
    ├── Qt5Gui.dll
    ├── Qt5Helpd.dll
    ├── Qt5Help.dll
    ├── Qt5Locationd.dll
    ├── Qt5Location.dll
    ├── Qt5Multimediad.dll
    ├── Qt5Multimedia.dll
    ├── Qt5MultimediaQuick_pd.dll
    ├── Qt5MultimediaQuick_p.dll
    ├── Qt5MultimediaWidgetsd.dll
    ├── Qt5MultimediaWidgets.dll
    ├── Qt5Networkd.dll
    ├── Qt5Network.dll
    ├── Qt5Nfcd.dll
    ├── Qt5Nfc.dll
    ├── Qt5OpenGLd.dll
    ├── Qt5OpenGL.dll
    ├── Qt5Positioningd.dll
    ├── Qt5Positioning.dll
    ├── Qt5PrintSupportd.dll
    ├── Qt5PrintSupport.dll
    ├── Qt5Purchasingd.dll
    ├── Qt5Purchasing.dll
    ├── Qt5Qmld.dll
    ├── Qt5Qml.dll
    ├── Qt5QuickControls2d.dll
    ├── Qt5QuickControls2.dll
    ├── Qt5Quickd.dll
    ├── Qt5Quick.dll
    ├── Qt5QuickParticlesd.dll
    ├── Qt5QuickParticles.dll
    ├── Qt5QuickTemplates2d.dll
    ├── Qt5QuickTemplates2.dll
    ├── Qt5QuickTestd.dll
    ├── Qt5QuickTest.dll
    ├── Qt5QuickWidgetsd.dll
    ├── Qt5QuickWidgets.dll
    ├── Qt5Scriptd.dll
    ├── Qt5Script.dll
    ├── Qt5ScriptToolsd.dll
    ├── Qt5ScriptTools.dll
    ├── Qt5Scxmld.dll
    ├── Qt5Scxml.dll
    ├── Qt5Sensorsd.dll
    ├── Qt5Sensors.dll
    ├── Qt5SerialBusd.dll
    ├── Qt5SerialBus.dll
    ├── Qt5SerialPortd.dll
    ├── Qt5SerialPort.dll
    ├── Qt5Sqld.dll
    ├── Qt5Sql.dll
    ├── Qt5Svgd.dll
    ├── Qt5Svg.dll
    ├── Qt5Testd.dll
    ├── Qt5Test.dll
    ├── Qt5WebChanneld.dll
    ├── Qt5WebChannel.dll
    ├── Qt5WebSocketsd.dll
    ├── Qt5WebSockets.dll
    ├── Qt5Widgetsd.dll
    ├── Qt5Widgets.dll
    ├── Qt5WinExtrasd.dll
    ├── Qt5WinExtras.dll
    ├── Qt5Xmld.dll
    ├── Qt5Xml.dll
    ├── Qt5XmlPatternsd.dll
    ├── Qt5XmlPatterns.dll
    ├── WindowsTest.exe
    ├── scenegraph
    │   ├── softwarecontextd.dll
    │   └── softwarecontext.dll
    ├── sceneparsers
    │   ├── assimpsceneiod.dll
    │   ├── assimpsceneio.dll
    │   ├── gltfsceneiod.dll
    │   └── gltfsceneio.dll
    ├── sensorgestures
    │   ├── qtsensorgestures_plugind.dll
    │   ├── qtsensorgestures_plugin.dll
    │   ├── qtsensorgestures_shakeplugind.dll
    │   └── qtsensorgestures_shakeplugin.dll
    ├── sensors
    │   ├── qtsensors_genericd.dll
    │   └── qtsensors_generic.dll
    ├── sqldrivers
    │   ├── qsqlited.dll
    │   ├── qsqlite.dll
    │   ├── qsqlmysqld.dll
    │   ├── qsqlmysql.dll
    │   ├── qsqlodbcd.dll
    │   ├── qsqlodbc.dll
    │   ├── qsqlpsqld.dll
    │   └── qsqlpsql.dll
    ├── ssleay32.dll
    ├── wxbase28u_net_vc_custom.dll
    ├── wxbase28u_vc_custom.dll
    ├── wxbase28u_xml_vc_custom.dll
    ├── wxmsw28u_adv_vc_custom.dll
    ├── wxmsw28u_aui_vc_custom.dll
    ├── wxmsw28u_core_vc_custom.dll
    ├── wxmsw28u_html_vc_custom.dll
    ├── wxmsw28u_stc_vc_custom.dll
    ├── wxmsw28u_xrc_vc_custom.dll
    └── zlib1.dll
    
    

    UPDATE: I tried to add libraries path manually using a.addLibraryPath() but unfortunately it didn't affect on the result.

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #2

    @mbnoimi
    can your application find the the libpq.dll?
    Since this should be a dependency for the plugin right?

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    M 1 Reply Last reply
    0
    • raven-worxR raven-worx

      @mbnoimi
      can your application find the the libpq.dll?
      Since this should be a dependency for the plugin right?

      M Offline
      M Offline
      mbnoimi
      wrote on last edited by mbnoimi
      #3

      @raven-worx

      I'm unable to check whether my app able to find libq.dll or not because Dependency walker doesn't show it in list of dependencies see the screenshot please.

      Any way I copied it as shown up here (even I copied all expected dependencies) but unfortunately I get this annoying error message.

      IMPORTANT: I get this error message even in case I run the app from Qt Creator too!!!

      raven-worxR 1 Reply Last reply
      0
      • M mbnoimi

        @raven-worx

        I'm unable to check whether my app able to find libq.dll or not because Dependency walker doesn't show it in list of dependencies see the screenshot please.

        Any way I copied it as shown up here (even I copied all expected dependencies) but unfortunately I get this annoying error message.

        IMPORTANT: I get this error message even in case I run the app from Qt Creator too!!!

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #4

        @mbnoimi
        you posted the dependency list of your application right?
        But libpq.dll is a dependency of the plugin only. And thats the reason why the loading fails i guess.

        Find the DLL on your machine (maybe in C:\Program Files\PostgreSQL\libraries)
        Then try one of the following:

        1. distribute the DLL beside the qpsql.dll plugin
        2. distribute the DLL beside your application exe
        3. add the path to the folder containing libpq.dll to the PATH environment variable (should work for sure)

        i am not 100% sure about the first 2 options though.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        M 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @mbnoimi
          you posted the dependency list of your application right?
          But libpq.dll is a dependency of the plugin only. And thats the reason why the loading fails i guess.

          Find the DLL on your machine (maybe in C:\Program Files\PostgreSQL\libraries)
          Then try one of the following:

          1. distribute the DLL beside the qpsql.dll plugin
          2. distribute the DLL beside your application exe
          3. add the path to the folder containing libpq.dll to the PATH environment variable (should work for sure)

          i am not 100% sure about the first 2 options though.

          M Offline
          M Offline
          mbnoimi
          wrote on last edited by
          #5

          @raven-worx
          May you please read my first post carefully :) I already put libpq.dll beside my app (option 2).

          Any way I tried your 3rd suggestion but I still get same result :(

          For 1st option I'm unable to find qpsql.dll any place in Qt binaries installation!

          raven-worxR 1 Reply Last reply
          0
          • M mbnoimi

            @raven-worx
            May you please read my first post carefully :) I already put libpq.dll beside my app (option 2).

            Any way I tried your 3rd suggestion but I still get same result :(

            For 1st option I'm unable to find qpsql.dll any place in Qt binaries installation!

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by raven-worx
            #6

            @mbnoimi

            For 1st option I'm unable to find qpsql.dll any place in Qt binaries installation!

            For example should be in C:\Qt\5.6\msvc2015\plugins\sqldrivers

            But to make sure, you can check where the application loads the plugins by setting the QT_DEBUG_PLUGINS to a non-zero value and look out for the psql plugin.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            M 1 Reply Last reply
            0
            • raven-worxR raven-worx

              @mbnoimi

              For 1st option I'm unable to find qpsql.dll any place in Qt binaries installation!

              For example should be in C:\Qt\5.6\msvc2015\plugins\sqldrivers

              But to make sure, you can check where the application loads the plugins by setting the QT_DEBUG_PLUGINS to a non-zero value and look out for the psql plugin.

              M Offline
              M Offline
              mbnoimi
              wrote on last edited by mbnoimi
              #7

              @raven-worx
              May you please read the check of QT_DEBUG_PLUGINS
              https://gist.github.com/mbnoimi/154b31a77a079c45bbdd63d4c1cfe3bc

              raven-worxR 1 Reply Last reply
              0
              • M mbnoimi

                @raven-worx
                May you please read the check of QT_DEBUG_PLUGINS
                https://gist.github.com/mbnoimi/154b31a77a079c45bbdd63d4c1cfe3bc

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by
                #8

                @mbnoimi
                the problem is this line

                QLibraryPrivate::loadPlugin failed on "C:/Qt/Qt5.7.0/5.7/mingw53_32/plugins/sqldrivers/qsqlpsqld.dll" : "Cannot load library C:\\Qt\\Qt5.7.0\\5.7\\mingw53_32\\plugins\\sqldrivers\\qsqlpsqld.dll: %1 is not a valid Win32 application."
                

                seems to be an psql specific error

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                M 1 Reply Last reply
                0
                • raven-worxR raven-worx

                  @mbnoimi
                  the problem is this line

                  QLibraryPrivate::loadPlugin failed on "C:/Qt/Qt5.7.0/5.7/mingw53_32/plugins/sqldrivers/qsqlpsqld.dll" : "Cannot load library C:\\Qt\\Qt5.7.0\\5.7\\mingw53_32\\plugins\\sqldrivers\\qsqlpsqld.dll: %1 is not a valid Win32 application."
                  

                  seems to be an psql specific error

                  M Offline
                  M Offline
                  mbnoimi
                  wrote on last edited by
                  #9

                  Thanks @raven-worx I did I mentioned in Stackoverflow link but unfortunately I still get same result.

                  NOTE: I update the log of QT_DEBUG_PLUGINS output:
                  https://gist.github.com/mbnoimi/154b31a77a079c45bbdd63d4c1cfe3bc

                  raven-worxR 1 Reply Last reply
                  0
                  • M mbnoimi

                    Thanks @raven-worx I did I mentioned in Stackoverflow link but unfortunately I still get same result.

                    NOTE: I update the log of QT_DEBUG_PLUGINS output:
                    https://gist.github.com/mbnoimi/154b31a77a079c45bbdd63d4c1cfe3bc

                    raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #10

                    @mbnoimi
                    so something is wrong with your psql binaries.

                    Maybe a mismatch between x86 and x64?

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    M 1 Reply Last reply
                    0
                    • raven-worxR raven-worx

                      @mbnoimi
                      so something is wrong with your psql binaries.

                      Maybe a mismatch between x86 and x64?

                      M Offline
                      M Offline
                      mbnoimi
                      wrote on last edited by
                      #11

                      @raven-worx

                      Maybe a mismatch between x86 and x64?

                      To be of mismatching between x86 and x64 I did:

                      1. Uninstalled postgres-9.3.4-4-windows-x64
                      2. installed postgres-9.3.13-windows
                      3. Copied runtime of postgres-9.3.13-windows beside my Qt app

                      I get same error message!!!

                      Now I'm pretty sure this problem is related to Qt SQL plugin so I'll try to build it by myself (I'll send the result after finish it)

                      raven-worxR 1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        Hi,

                        Did you check that you have a MinGW build of PostgreSQL ?

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

                        M 1 Reply Last reply
                        0
                        • SGaistS SGaist

                          Hi,

                          Did you check that you have a MinGW build of PostgreSQL ?

                          M Offline
                          M Offline
                          mbnoimi
                          wrote on last edited by
                          #13

                          @SGaist Usually Postgresql guys don't use MinGW so their binaries built using MSVS

                          1 Reply Last reply
                          0
                          • M mbnoimi

                            @raven-worx

                            Maybe a mismatch between x86 and x64?

                            To be of mismatching between x86 and x64 I did:

                            1. Uninstalled postgres-9.3.4-4-windows-x64
                            2. installed postgres-9.3.13-windows
                            3. Copied runtime of postgres-9.3.13-windows beside my Qt app

                            I get same error message!!!

                            Now I'm pretty sure this problem is related to Qt SQL plugin so I'll try to build it by myself (I'll send the result after finish it)

                            raven-worxR Offline
                            raven-worxR Offline
                            raven-worx
                            Moderators
                            wrote on last edited by
                            #14

                            @mbnoimi said:

                            Now I'm pretty sure this problem is related to Qt SQL plugin so I'll try to build it by myself (I'll send the result after finish it)

                            I don't know what makes you think that but try it if you want to.

                            What is the content of your PATH env variable? Is there a reference to the psql install dir?

                            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                            If you have a question please use the forum so others can benefit from the solution in the future

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

                              Hence your problem: you are currently using the MinGW build of Qt, so unless you have a MinGW version of PostgreSQL your only option is to use a MSVC build of Qt matching the version used by PostgreSQL.

                              In any case, the PostgreSQL folks have provided a wiki page about MinGW here.

                              Hope it helps

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

                              raven-worxR M 3 Replies Last reply
                              1
                              • SGaistS SGaist

                                Hence your problem: you are currently using the MinGW build of Qt, so unless you have a MinGW version of PostgreSQL your only option is to use a MSVC build of Qt matching the version used by PostgreSQL.

                                In any case, the PostgreSQL folks have provided a wiki page about MinGW here.

                                Hope it helps

                                raven-worxR Offline
                                raven-worxR Offline
                                raven-worx
                                Moderators
                                wrote on last edited by
                                #16

                                @SGaist
                                that makes sense of course.
                                One would expect that the Postgresql devs would export the symbols using "C-style" to avoid such problems?!

                                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                                If you have a question please use the forum so others can benefit from the solution in the future

                                1 Reply Last reply
                                1
                                • SGaistS SGaist

                                  Hence your problem: you are currently using the MinGW build of Qt, so unless you have a MinGW version of PostgreSQL your only option is to use a MSVC build of Qt matching the version used by PostgreSQL.

                                  In any case, the PostgreSQL folks have provided a wiki page about MinGW here.

                                  Hope it helps

                                  M Offline
                                  M Offline
                                  mbnoimi
                                  wrote on last edited by
                                  #17

                                  @SGaist Do you know any binaries of PG built by MinGW?

                                  1 Reply Last reply
                                  0
                                  • SGaistS SGaist

                                    Hence your problem: you are currently using the MinGW build of Qt, so unless you have a MinGW version of PostgreSQL your only option is to use a MSVC build of Qt matching the version used by PostgreSQL.

                                    In any case, the PostgreSQL folks have provided a wiki page about MinGW here.

                                    Hope it helps

                                    M Offline
                                    M Offline
                                    mbnoimi
                                    wrote on last edited by
                                    #18

                                    Thank you very much @SGaist and @raven-worx for helping me out. I fixed this issue by using runtime libraries from this project:
                                    https://sourceforge.net/projects/postgresql-mingw-w64/

                                    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