1
votes

I am trying to load psql on qt without success. My code:

QApplication a(argc, argv);
QSqlDatabase::addDatabase("QPSQL");
MainWindow w;
w.show();
return a.exec();

I have QT_DEBUG_PLUGINS enabled. Output is:

"The plugin 'C:/Qt/5.1.1/mingw48_32/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" not a plugin QFactoryLoader::QFactoryLoader() looking at "C:/Qt/5.1.1/mingw48_32/plugins/sqldrivers/qsqlpsqld.dll" Got keys from plugin meta data ("QPSQL7", "QPSQL") QFactoryLoader::QFactoryLoader() checking directory path "C:/build-Hello-Desktop_Qt_5_1_1_MinGW_32bit-Debug/debug/sqldrivers" ... loaded library "C:/Qt/5.1.1/mingw48_32/plugins/sqldrivers/qsqlpsqld.dll" QLibraryPrivate::loadPlugin failed on "C:/Qt/5.1.1/mingw48_32/plugins/sqldrivers/qsqlpsqld.dll" : "Cannot load library C:/Qt/5.1.1/mingw48_32/plugins/sqldrivers/qsqlpsqld.dll: The specified module could not be found." QSqlDatabase: QPSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7

My configuration:

- Windows 7 Enterprise
- Qt Creator 2.8.1
- Qt 5.1.1
- Postgre 9.2
- C:\PostgreSQL\9.2\bin; C:\PostgreSQL\9.2\lib added to PATH

I have run dependency walker for the libpg.dll. Two missing dependencies:

  • GPSVC.DLL
  • IESHIMS.DLL

It seems that after these steps my effort is going to less organised "just-try-something...".

3
Maybe you must add some dynamic libraries (DLL in WIndows) in your app output directory/sqldrivers directory - Didac Perez Parera
I added GPSVC.DLL and IESHIMS.DLL to sqldrivers directory. No effect - Juhhi
Did you compile your Qt yourself? - Greenflow
No, I downloaded the ready made package - Juhhi
GPSVC.DLL and IESHIMS.DLL do not mind. - Didac Perez Parera

3 Answers

1
votes

The first error message more or less tells everything:

The plugin 'C:/Qt/5.1.1/mingw48_32/plugins/sqldrivers/qsqlpsql.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"

I suppose your program is compiled in debug mode, but you are missing Qt plugins, which where compiled in debug mode. How this happened, since you said you used are ready made package... No idea.

Try to compile your program in release mode. In .pro: CONFIG+=release.

1
votes

Had the same problem. It is usually the fact that you're using 32-bit Qt with 64-bit Postgresql. I downloaded the 32-bit postgresql, changed the path(in Qt creator) to the 32-bit postgre libraries and everything worked flawlessly.

Using: Qt 5.2.0, 32bit (from SDK) PostgreSQL 9.3(x86)

0
votes

try to recompile the PostgreSQl dll