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. QPSQL driver not loaded

QPSQL driver not loaded

Scheduled Pinned Locked Moved Solved General and Desktop
22 Posts 4 Posters 11.6k 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.
  • jsulmJ jsulm

    @ivanicy said in QPSQL driver not loaded:

    What could be happening?

    Set QT_DEBUG_PLUGINS environment variable to one 1 before starting your application, start your app and check the output (or post it here).

    ivanicyI Offline
    ivanicyI Offline
    ivanicy
    wrote on last edited by
    #4

    @jsulm Ok, this is the output of my example app that works fine:

    Got keys from plugin meta data ("QPSQL7", "QPSQL")
    QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Ivan/Desktop/Pruebas/DataBase/build-DataBase-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug/debug/sqldrivers" ...
    loaded library "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlpsqld.dll"
    

    And this is the output for my other app that doesn't work:

    Cannot load library C:\Users\Ivan\Desktop\Proyectos\sw_RedLook_Fix\build-sw_RedLook_Fix-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug\debug\sqldrivers\qsqlpsqld.dll: No se puede encontrar el módulo especificado.
    QLibraryPrivate::loadPlugin failed on "C:/Users/Ivan/Desktop/Proyectos/sw_RedLook_Fix/build-sw_RedLook_Fix-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug/debug/sqldrivers/qsqlpsqld.dll" : "Cannot load library C:\\Users\\Ivan\\Desktop\\Proyectos\\sw_RedLook_Fix\\build-sw_RedLook_Fix-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug\\debug\\sqldrivers\\qsqlpsqld.dll: No se puede encontrar el módulo especificado."
    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    

    Apparently in the first case it is taking the dll from msvc2017 and in the second from the program folder it is not? How can I change it?

    Thank you very much!

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #5

      You can delete the 'sqldrivers' folder (and any other Qt plugin folders) from your build directory; it should then load from the Qt directory.

      ivanicyI 1 Reply Last reply
      0
      • M mchinand

        You can delete the 'sqldrivers' folder (and any other Qt plugin folders) from your build directory; it should then load from the Qt directory.

        ivanicyI Offline
        ivanicyI Offline
        ivanicy
        wrote on last edited by
        #6

        @mchinand It has been created again this folder when I execute and I don't know why.

        M 1 Reply Last reply
        0
        • ivanicyI ivanicy

          @mchinand It has been created again this folder when I execute and I don't know why.

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

          Can you post your .pro project file?

          ivanicyI 1 Reply Last reply
          0
          • M mchinand

            Can you post your .pro project file?

            ivanicyI Offline
            ivanicyI Offline
            ivanicy
            wrote on last edited by
            #8

            @mchinand In .pro file I only add "QT += sql". But I don't why it can't find the qsqlpsqld.dll file. This dll is in the sqldrivers folder. How can I make the QFactoryLoader look in the correct folder?

            M 1 Reply Last reply
            0
            • ivanicyI ivanicy

              @mchinand In .pro file I only add "QT += sql". But I don't why it can't find the qsqlpsqld.dll file. This dll is in the sqldrivers folder. How can I make the QFactoryLoader look in the correct folder?

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

              Is there an install or post-build step in your project file?

              ivanicyI 1 Reply Last reply
              0
              • M mchinand

                Is there an install or post-build step in your project file?

                ivanicyI Offline
                ivanicyI Offline
                ivanicy
                wrote on last edited by
                #10
                This post is deleted!
                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mchinand
                  wrote on last edited by
                  #11

                  Do you have the postgres Qt plugin in one of the many directories you are copying?

                  ivanicyI 1 Reply Last reply
                  0
                  • M mchinand

                    Do you have the postgres Qt plugin in one of the many directories you are copying?

                    ivanicyI Offline
                    ivanicyI Offline
                    ivanicy
                    wrote on last edited by
                    #12

                    @mchinand I have another clue. I have tried to execute the application from the application folder (out of Qt) and it works...

                    M 1 Reply Last reply
                    0
                    • ivanicyI ivanicy

                      @mchinand I have another clue. I have tried to execute the application from the application folder (out of Qt) and it works...

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

                      When you say 'out of Qt' do you mean not from QtCreator?

                      ivanicyI 1 Reply Last reply
                      0
                      • M mchinand

                        When you say 'out of Qt' do you mean not from QtCreator?

                        ivanicyI Offline
                        ivanicyI Offline
                        ivanicy
                        wrote on last edited by
                        #14

                        @mchinand Yeah, I mean, opening the .exe directly

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

                          Hi,

                          Did you build the plugin both for debug and release ?

                          Note that the length of your application output with regard to the QPSQL driver messages indicates that you likely did not properly set the QT_DEBUG_PLUGINS environment in Qt Creator. It should be done in the Run part of the Project panel.

                          You should be swamped with plugin related messages and have something more informative with regard to what happens when the plugin loading fails.

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

                          ivanicyI 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Hi,

                            Did you build the plugin both for debug and release ?

                            Note that the length of your application output with regard to the QPSQL driver messages indicates that you likely did not properly set the QT_DEBUG_PLUGINS environment in Qt Creator. It should be done in the Run part of the Project panel.

                            You should be swamped with plugin related messages and have something more informative with regard to what happens when the plugin loading fails.

                            ivanicyI Offline
                            ivanicyI Offline
                            ivanicy
                            wrote on last edited by ivanicy
                            #16

                            @SGaist I have this:

                            Got keys from plugin meta data ("QPSQL7", "QPSQL")
                            Cannot load library C:\Users\Ivan\Desktop\Proyectos\sw_RedLook_Fix\build-sw_RedLook_Fix-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug\debug\sqldrivers\qsqlpsqld.dll: No se puede encontrar el módulo especificado.
                            QLibraryPrivate::loadPlugin failed on "C:/Users/Ivan/Desktop/Proyectos/sw_RedLook_Fix/build-sw_RedLook_Fix-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug/debug/sqldrivers/qsqlpsqld.dll" : "Cannot load library C:\\Users\\Ivan\\Desktop\\Proyectos\\sw_RedLook_Fix\\build-sw_RedLook_Fix-Desktop_Qt_5_14_2_MSVC2017_64bit-Debug\\debug\\sqldrivers\\qsqlpsqld.dll: No se puede encontrar el módulo especificado."
                            QSqlDatabase: QPSQL driver not loaded
                            QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
                            Error al abrir:  "Driver not loaded Driver not loaded"
                            ERROR:  "Driver not loaded Driver not loaded"
                            

                            I have two doubts here:

                            1. ¿Why it couldn't find qsqlpsqld.dll file if the path is correct. I have this dll in sqldrivers folder.

                            7ed96fa7-fb01-4f97-b1d5-baabf52e0f6f-image.png

                            1. Why Qt creates this folder there if in my example application it doesn't create anything (and it works correctly)
                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #17

                              One thing I did not realise directly is that it tries to load them from your application folder.
                              How did the plugins go there ?
                              Did you run windeployqt at some point in that folder ?

                              Did you build the plugins yourself ?

                              Do you have the PostreSQL .dll contains folder in your PATH environment variable ?

                              One important thing: all the manipulations of the environment variables should be done within Qt Creator and not at your machine level.

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

                              ivanicyI 1 Reply Last reply
                              0
                              • SGaistS SGaist

                                One thing I did not realise directly is that it tries to load them from your application folder.
                                How did the plugins go there ?
                                Did you run windeployqt at some point in that folder ?

                                Did you build the plugins yourself ?

                                Do you have the PostreSQL .dll contains folder in your PATH environment variable ?

                                One important thing: all the manipulations of the environment variables should be done within Qt Creator and not at your machine level.

                                ivanicyI Offline
                                ivanicyI Offline
                                ivanicy
                                wrote on last edited by ivanicy
                                #18

                                @SGaist I have this in .pro. But I have it before add QT += sql:

                                    isEmpty(TARGET_EXT) {
                                        TARGET_CUSTOM_EXT = .exe
                                    } else {
                                        TARGET_CUSTOM_EXT = $${TARGET_EXT}
                                    }
                                
                                    DEPLOY_COMMAND = windeployqt
                                
                                    CONFIG( debug, debug|release ) {
                                        # debug
                                        DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/debug/$${TARGET}$${TARGET_CUSTOM_EXT}))
                                    } else {
                                        # release
                                        DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/release/$${TARGET}$${TARGET_CUSTOM_EXT}))
                                    }
                                
                                    #Uncomment the following line to help debug the deploy command when running qmake
                                    #warning($${DEPLOY_COMMAND} $${DEPLOY_TARGET})
                                
                                    QMAKE_POST_LINK = $${DEPLOY_COMMAND} $${DEPLOY_TARGET}
                                

                                I do the same thing in both applications, I only add QT += sql

                                ivanicyI 1 Reply Last reply
                                0
                                • ivanicyI ivanicy

                                  @SGaist I have this in .pro. But I have it before add QT += sql:

                                      isEmpty(TARGET_EXT) {
                                          TARGET_CUSTOM_EXT = .exe
                                      } else {
                                          TARGET_CUSTOM_EXT = $${TARGET_EXT}
                                      }
                                  
                                      DEPLOY_COMMAND = windeployqt
                                  
                                      CONFIG( debug, debug|release ) {
                                          # debug
                                          DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/debug/$${TARGET}$${TARGET_CUSTOM_EXT}))
                                      } else {
                                          # release
                                          DEPLOY_TARGET = $$shell_quote($$shell_path($${OUT_PWD}/release/$${TARGET}$${TARGET_CUSTOM_EXT}))
                                      }
                                  
                                      #Uncomment the following line to help debug the deploy command when running qmake
                                      #warning($${DEPLOY_COMMAND} $${DEPLOY_TARGET})
                                  
                                      QMAKE_POST_LINK = $${DEPLOY_COMMAND} $${DEPLOY_TARGET}
                                  

                                  I do the same thing in both applications, I only add QT += sql

                                  ivanicyI Offline
                                  ivanicyI Offline
                                  ivanicy
                                  wrote on last edited by
                                  #19

                                  @ivanicy When I open the .exe in the application folder, if the sqldrivers folder exists and has the dll, the application works fine, but I don't know why doesn't work when I execute from Qt.

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

                                    Nuke your build folder and remove the windeployqt call. Do you still have the problem ?

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

                                    ivanicyI 1 Reply Last reply
                                    0
                                    • SGaistS SGaist

                                      Nuke your build folder and remove the windeployqt call. Do you still have the problem ?

                                      ivanicyI Offline
                                      ivanicyI Offline
                                      ivanicy
                                      wrote on last edited by ivanicy
                                      #21

                                      @SGaist I have the same problem. I have removed the execution folder and comment the QMAKE_POST_LINK line, but it doesn't work. I'm a little desperate, but I am very grateful for your time.

                                      ivanicyI 1 Reply Last reply
                                      0
                                      • ivanicyI ivanicy

                                        @SGaist I have the same problem. I have removed the execution folder and comment the QMAKE_POST_LINK line, but it doesn't work. I'm a little desperate, but I am very grateful for your time.

                                        ivanicyI Offline
                                        ivanicyI Offline
                                        ivanicy
                                        wrote on last edited by ivanicy
                                        #22

                                        @ivanicy Well, I have solved the problem. I have copied this dlls from PostgreSQL to the .exe folder:

                                        libiconv-2.dll
                                        libintl-8.dll
                                        libpq.dll

                                        and... it works!!

                                        Maybe the problem was that I created this app before I installed the PostgreSQL and the app doesn't integrate the postgre dlls or something like that.

                                        In any case, copying this dlls solves the problem. Thank you very much guys for your help!!

                                        1 Reply Last reply
                                        2

                                        • Login

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