QPSQL driver not loaded
-
wrote on 3 Feb 2022, 13:59 last edited by
Is your PATH (or the PATH of your Run environment if you're starting them within QtCreator) the same when you run the two applications? The location of the Postgres libraries (from Postgres, not supplied with Qt) needs to be in your PATH.
-
@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).
wrote on 3 Feb 2022, 14:44 last edited by@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!
-
wrote on 3 Feb 2022, 15:06 last edited by
You can delete the 'sqldrivers' folder (and any other Qt plugin folders) from your build directory; it should then load from the Qt directory.
-
You can delete the 'sqldrivers' folder (and any other Qt plugin folders) from your build directory; it should then load from the Qt directory.
-
wrote on 3 Feb 2022, 15:19 last edited by
Can you post your .pro project file?
-
@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?
wrote on 3 Feb 2022, 15:43 last edited byIs there an install or post-build step in your project file?
-
wrote on 3 Feb 2022, 15:58 last edited byThis post is deleted!
-
wrote on 3 Feb 2022, 16:11 last edited by
Do you have the postgres Qt plugin in one of the many directories you are copying?
-
@mchinand I have another clue. I have tried to execute the application from the application folder (out of Qt) and it works...
wrote on 3 Feb 2022, 18:19 last edited byWhen you say 'out of Qt' do you mean not from QtCreator?
-
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.
-
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.
wrote on 4 Feb 2022, 08:37 last edited by ivanicy 2 Apr 2022, 08:40@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:
- ¿Why it couldn't find qsqlpsqld.dll file if the path is correct. I have this dll in sqldrivers folder.
- Why Qt creates this folder there if in my example application it doesn't create anything (and it works correctly)
-
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.
-
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.
wrote on 4 Feb 2022, 08:54 last edited by ivanicy 2 Apr 2022, 08:57@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
-
@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
-
Nuke your build folder and remove the windeployqt call. Do you still have the problem ?
-
@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.
wrote on 7 Feb 2022, 08:55 last edited by ivanicy 2 Jul 2022, 08:59@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.dlland... 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!!
12/22