简体   繁体   中英

Qt Driver Postgresql available but not loaded

I'm trying to make a sample project, to read the data in my database.

I'm using Qt 5.8 on Windows 10, with mingw 32 bits compiler. Postgresql 9.6 32 bits.

I have the error : QSqlDatabase: QPSQL driver not loaded

QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

I tried to add in my Path:

-PostgresPath\\

-PostgresPath\\include

-PostgresPath\\bin

-PostgresPath\\lib

I tried to copy libeay32.dll, libintl-8.dll, libpq.dll, ssleay32.dll in QTPath\\5.8\\mingw53_32\\bin.

I tried to add libpq.dll, qsqlpsql.dll and qsqlpsqld.dll in my project folder but it doesn't help.

Do you have any advice ? Thanks.

Maybe you do not have the exact QPSQL plugin version you actually use for development (for example due to Qt framework upgrading etc.), so the plugin exists but cannot be loaded. Try to manually build the Qt PSQL driver plugin. Download the exact version of Qt source code (5.8.0 in your case) and run following commands. I assume that PostgreSQL was installed in C: \\ psql, and the Qt source code is in% QTDIR%, build the plugin as follows:

 cd %QTDIR%\src\plugins\sqldrivers\psql
 qmake -o Makefile "INCLUDEPATH+=C:\psql\include" "LIBS+=C:\psql\lib\ms\libpq.lib" psql.pro
 nmake

This works for me when I had similar problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM