Unsolved Postgresql driver is not found
-
@Bonnie
Thanks for advice. Now application debug output looks like this:Got keys from plugin meta data ("QPSQL7", "QPSQL") loaded library "…/debug/sqldrivers/qsqlpsql.dll" QFactoryLoader::QFactoryLoader() checking directory path "…/debug/accessible" ... QFactoryLoader::QFactoryLoader() checking directory path "…/debug/accessiblebridge" ... QLibraryPrivate::unload succeeded on "…/debug/sqldrivers/qsqlpsql.dll" QLibraryPrivate::unload succeeded on "…/debug/platforms/qwindows.dll" 21:31:17: *.exe exited with code 0
But I still catch "Driver not loaded" using this code:
if (!this->app_conn.isValid()) { //… } if (!this->app_conn.open()) { //… }
-
Can you show the code your are actually using to setup the database ?
The output you show does not present any error quite the contrary.
-
this->app_conn = QSqlDatabase(); this->app_conn.addDatabase(this->db_type); this->app_conn.setDatabaseName(this->db_name); this->app_conn.setHostName(this->db_host); this->app_conn.setPort(this->db_port); this->app_conn.setUserName(this->user_name); this->app_conn.setPassword(this->user_password);
this->db_type is "QPSQL".
-
You are using QSqlDatabase in the wrong manner.
addDatabase
is a static member, you are manipulating an invalid object.As the QSqlDatabase warns about: do not store local variables of that type. The class already provides everything needed to handle the objects you create from it.
-
-
So is it necessary to grab all "Debug" DLLs and place them to "Release"? How to avoid this crutch?
-
What debug dll ?
-
\sqldrivers\qsqlpsql.dll \platforms\qwindows.dll \vcruntime140.dll \Qt5Sql.dll \Qt5Core.dll \msvcrt.dll \libstdc++-6.dll \libssl-1_1-x64.dll \libpq.dll \libintl-8.dll \libiconv-2.dll \libcrypto-1_1-x64.dll
-
Ah, you meant the content of the Debug folder.
One thing you can do is go in the Run part of the Project panel and modify the PATH environment variable to include the path to these dlls.
-
@SGaist
I've made additional folder inside my project and move all DLLs into it. After that add path to this folder in PATH variable. It works but this method is crutch anyway… -
On Windows there's two way to find .dlls:
- they are in the same folder
- they are in a folder in your PATH environment variable
Qt Creator does the change for Qt for you based on which kit you are using. Since you use external dependencies, it's up to you to provide a mean to find your dependencies dlls. And no, modifying your system's PATH environment is not the correct way.
-
@alxdef
Why?
On windows the most usual way is just putting the dependency dlls with the exe, famous software products also do like that.