I installed PostgreSQL, then downloaded and installed libpq64. Afterwards, I downloaded the Qt 4.6.2 source code and compiled it successfully with Visual Studio 2008. After providing the path to the libs in libpq64, I compiled the QPSQL sucessfully too.

My sql plugin folder contains the following files:
Qt Code:
  1. V:\windows\x64\QT-4.6.2_VC9.0_Bin\plugins\sqldrivers>dir *.dll
  2. Datenträger in Laufwerk V: ist Data
  3. Verzeichnis von V:\windows\x64\QT-4.6.2_VC9.0_Bin\plugins\sqldrivers
  4. qsqlite4.dll
  5. qsqlited4.dll
  6. qsqlpsql4.dll
  7. qsqlpsqld4.dll
To copy to clipboard, switch view to plain text mode 

I use a simple test program:

Qt Code:
  1. main(int argc , char* argv[])
  2. {
  3. QApplication app(argc,argv); // load plugins
  4. std::cout << "QSqlDatabase::drivers() output: " << QSqlDatabase::drivers().join(QString("; ")).toLatin1().data() << "\n"; //
  5. output of all loaded sql plugins
  6.  
  7. return 0;
  8. }
To copy to clipboard, switch view to plain text mode 

The output in Release Mode:
QSqlDatabase::drivers(): QSQLITE; QPSQL7; QPSQL

The output in Debug Mode:
QSqlDatabase::drivers(): QSQLITE

As you can see, the QPSQL plugin is not loaded in debug mode.


I debugged into the qt code, the problem is in
qlibrary_win.cpp Line 70:
Qt Code:
  1. pHnd = LoadLibrary((wchar_t*)QDir::toNativeSeparators(attempt).utf16());
To copy to clipboard, switch view to plain text mode 
returns 0x00000000 for qsqlpsqld4.dll


My PATH variable contains
Qt Code:
  1. PATH=V:\windows\x64\QT-4.6.2_VC9.0_Bin\bin;V:\windows\x64\libpq64;"V:\toolkits\windows\x64\PostgreSQL\bin";[...]
To copy to clipboard, switch view to plain text mode 
These paths contain the following DLLs:
Qt Code:
  1. libeay32.dll
  2. libpq.dll
  3. ssleay32.dll
  4.  
  5. comerr32.dll
  6. gssapi32.dll
  7. iconv.dll
  8. k5sprt32.dll
  9. krb5_32.dll
  10. libeay32.dll
  11. libiconv-2.dll
  12. libintl-8.dll
  13. libpq.dll
  14. libxml2.dll
  15. libxslt.dll
  16. msvcr71.dll
  17. ssleay32.dll
  18. zlib1.dll
To copy to clipboard, switch view to plain text mode 

What am I missing? How can I use the QPSQL plugin in debug mode?

Thank you for your help.