QMYSQL , QPSQL , QPSQL7 ! Driver not found
-
Hi,
I'm new at using QT with database ; i've been developing using many dev language and this time i wanted to learn QT & C++ in order to start creating embedded soft.
When i try to load QMYSQL or QPSQL or QPSQL7 does not work.
My QT Version is 5.15 ; OS: Windows 10 64
and i tried the solutions provided on the documentation but does not work !!! My App need to be x32 so i'm using Mingw32 and the tool is MinGw81_32 . Any Help Please !? -
@tmapp said in QMYSQL , QPSQL , QPSQL7 ! Driver not found:
When i try to load QMYSQL or QPSQL or QPSQL7 does not work.
You should copy & paste the error message you receive when you have such a problem.
In any case, the answer is always the same for this issue: you need to set environment variable named
QT_DEBUG_PLUGINS
to value1
. If running your program from Command Prompt:set QT_DEBUG_PLUGINS=1 /path/to/your/application.exe
Or if you run your app from Qt Creator it has a "Run Environment" or similar where you can set this variable.
Your program will then produce lines of diagnostic output indicating where your problem emanates from.
-
@JonB
The Error Message Always say : QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
in the moment where : qpsql*.dll exists in sqldrivers folder. I even tried the exemple found in the projects about the SQL database, in the selection there is PSQLITE, QPSQL and QODBC , but when using QPSQL and i give the information about the connection same Error : driver not loaded -
@JonB
Yep I did :
------------------------------------ Information -------------
section .gnu_debuglink not found in C:\Qt\QT5\5.15.1\mingw81_32\plugins\sqldrivers\qsqlpsql.dll.debug
section .gnu_debuglink not found in C:\Qt\QT5\5.15.1\mingw81_32\plugins\sqldrivers\qsqlpsql.dll.debug
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7AND on the QT SQL Browser : an error occured while opening the connection : Driver not loaded Driver not loaded.
-
@JonB
in the project setting i added it in the environement build :
and the last output i'm getting now :
Cannot load library C:\Qt\QT5\5.15.1\mingw81_32\plugins\sqldrivers\qsqlpsql.dll: The specified module could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Qt/QT5/5.15.1/mingw81_32/plugins/sqldrivers/qsqlpsql.dll" : "Cannot load library C:\Qt\QT5\5.15.1\mingw81_32\plugins\sqldrivers\qsqlpsql.dll: The specified module could not be found."
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7 -
As always with this topic (the forum search function is a nice tool btw...) make sure the required libraries for the plugin are in the PATH.
-
@tmapp
I am not an expert here, but: I believe that if that.DLL
file has missing dependencies (other DLLs) which it cannot find or cannot load, the error message you get is that the first one "could not be found", like yours shows. There is some Windows Dependency Walker app you can download which would allow you to see what other DLLs that DLL needs.That's all I know, unless someone else knows better. You might find other references if you Google/search this forum for
QPSQL driver not loaded
. -
@mchinand
i copied files in the bin path of the mingw folder (libpq.dll and other dll found in a video of postgresql in youtube ) but doesn't work. I started by Mysql and when i saw qpsql*.dll I changed to it but same errors.
@JonB first thank you very much for your help and time , second yeah naturally i google it before , this is my first time posting a question in a forum, all times i google, but this one ! -
Where did you get the libpq and related dlls? You should copy them to the same folder as your project's executable (looks like build-sqlbrowser-Desktop_Qt_15_1_MinGW_32_bit-Debug) or add whatever folder they are in to your PATH environment variable (and restart QtCreator aftewards).
-
@mchinand same problem , no result . I even tried to remake the driver yet an error occured when making :
g++: error: unrecognized command line option '-std=c++1z' g++: error: unrecognized command line option '-Wshift-overflow=2' g++: error: unrecognized command line option '-Wduplicated-cond' mingw32-make[2]: *** [Makefile.Release:403: .obj/release/qsql_sqlite.o] Error 1 mingw32-make[2]: Leaving directory 'C:/Qt/QT5/5.15.1/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make[1]: *** [Makefile:45: release] Error 2 mingw32-make[1]: Leaving directory 'C:/Qt/QT5/5.15.1/Src/qtbase/src/plugins/sqldrivers/sqlite' mingw32-make: *** [Makefile:50: sub-sqlite-make_first] Error 2
-
Hi Again , I solved the problem :: i had to remake the driver and after googling and looking in the forum many guys had the same problem with the actual driver and remaking new one. Here is how to do :
- I'm using Postgresql 10.
1. you need to download the zip file of postgresql where source code exist. 2. lunch the Qt Mingw console. 3. copy all the file exists in the include path of the download zip in %Path_TO_QT\src\qtbase\plugins\sqldrivers\psql ( if you don't you'll have problems with include files .h in mingw32-make 4. make sur to copy the lib files to the same folder psql ( libpq.dll , libeay32.dll, libintl , libiconv, ssleay32.dll ) ssleay32 you can have i from the net ( i got it from my xampp folder) 5. edit the file psql.pro and comment : QMAKE_USE += psql with a # if you don't you'll have error : psql model not defined 6. run the qmake command as follow: qmake "INCLUDEPATH+=PATH_TO_DOWNLOAD_SOURCE\pgsql\include" "LIBS+=PATH_TO_DOWNLOADED_SOURCE\pgsql\lib" psql.pro here PATH_TO_DOWNLOAD_SOURCE mean the path to the download zip extracted 7. run mingw32-make 8. run mingw32-make install
Congrats.
@Christian-Ehrlicher @JonB @mchinand thanks for your time and help :)