Problem using the QPSQL plugin on Windows x64 in Debug mode
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:
Code:
V:\windows\x64\QT-4.6.2_VC9.0_Bin\plugins\sqldrivers>dir *.dll
Datenträger in Laufwerk V: ist Data
Verzeichnis von V:\windows\x64\QT-4.6.2_VC9.0_Bin\plugins\sqldrivers
qsqlite4.dll
qsqlited4.dll
qsqlpsql4.dll
qsqlpsqld4.dll
I use a simple test program:
Code:
main(int argc , char* argv[])
{
std
::cout <<
"QSqlDatabase::drivers() output: " <<
QSqlDatabase::drivers().
join(QString("; ")).
toLatin1().
data() <<
"\n";
//output of all loaded sql plugins
return 0;
}
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:
Code:
pHnd
= LoadLibrary
((wchar_t*)QDir::toNativeSeparators(attempt
).
utf16());
returns 0x00000000 for qsqlpsqld4.dll
My PATH variable contains
Code:
PATH=V:\windows\x64\QT-4.6.2_VC9.0_Bin\bin;V:\windows\x64\libpq64;"V:\toolkits\windows\x64\PostgreSQL\bin";[...]
These paths contain the following DLLs:
Code:
libeay32.dll
libpq.dll
ssleay32.dll
comerr32.dll
gssapi32.dll
iconv.dll
k5sprt32.dll
krb5_32.dll
libeay32.dll
libiconv-2.dll
libintl-8.dll
libpq.dll
libxml2.dll
libxslt.dll
msvcr71.dll
ssleay32.dll
zlib1.dll
What am I missing? How can I use the QPSQL plugin in debug mode?
Thank you for your help.
Re: Problem using the QPSQL plugin on Windows x64 in Debug mode
I tried to SET QT_DEBUG_PLUGINS=1 to get more debug information
Code:
QFactoryLoader::QFactoryLoader() looking at "V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlite4.dll"
In V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlite4.dll:
Plugin uses incompatible Qt library
expected build key "Windows x64 msvc debug full-config", got "Windows x64 msvc release full-config"
"The plugin 'V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlite4.dll' uses incompatible Qt library. Expected b
uild key "Windows x64 msvc debug full-config", got "Windows x64 msvc release full-config""
not a plugin
QFactoryLoader::QFactoryLoader() looking at "V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlited4.dll"
keys ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlpsql4.dll"
In V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlpsql4.dll:
Plugin uses incompatible Qt library
expected build key "Windows x64 msvc debug full-config", got "Windows x64 msvc release full-config"
"The plugin 'V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlpsql4.dll' uses incompatible Qt library. Expected
build key "Windows x64 msvc debug full-config", got "Windows x64 msvc release full-config""
not a plugin
QFactoryLoader::QFactoryLoader() looking at "V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlpsqld4.dll"
"Cannot load library V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlpsqld4.dll: "
could not load
<-- it just can not load qsqlpsqld4.dll :(
In release mode, the output is as expected:
Code:
QFactoryLoader::QFactoryLoader() looking at "V:/windows/x64/QT-4.6.2_VC9.0_Bin/plugins/sqldrivers/qsqlpsql4.dll"
keys ("QPSQL7", "QPSQL")[/QUOTE]
using the dependency walker, I get an error "MSVCR90D.DLL can not be found". Adding the folder "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist\amd64\Microsoft.VC90 .DebugCRT" that contains the dll to the path did not make the plugin load (but the dependency walker error message disapeared).
The next error message from dependency walker is "Error: Modules with different CPU types were found."
Browsing the module list, I found that MSVCR90.DLL for x86 (!) seems to be a required module for qsqlpsql4.dll.
Could this be the cause for the failed plugin loading? How can I fix this?
Re: Problem using the QPSQL plugin on Windows x64 in Debug mode
Okay, I did some more experimentation:
adding
Code:
@SET PATH=%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\redist\Debug_NonRedist\amd64\Microsoft.VC90.DebugCRT;%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\redist\amd64\Microsoft.VC90.CRT;%PATH%
to the front of my path made sure that the correct x64 DLLs are found first. Now, Dependency Walker does not complain anymore. Running my test program raises an error message:
Code:
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Runtime Error!
Program: d:\...
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
Of course, the QPSQL driver is not loaded...
R6034 hints at a missing manifest file. But my visual studio project settings are set to embed the manifest into my .exe.
I'm lost, I have no idea how to get this working :(
Re: Problem using the QPSQL plugin on Windows x64 in Debug mode
Now it is getting strange:
I removed the QApplication app(argc,argv) line which should be responsible for loading the plugins, startet in release mode and the plugin was still loaded:
Code:
//QApplication app(argc,argv);
MITK_INFO <<
"QSqlDatabase::drivers(): " <<
QSqlDatabase::drivers().
join(QString("; ")).
toLatin1().
data() <<
"\n";
Output:
I'm confused, I thought that the plugins are loaded during instantiation of QApplication?
Re: Problem using the QPSQL plugin on Windows x64 in Debug mode
I have been experiencing the same problem on Windows XP 32 bit edition.
I just want to comment on QApplication loading the plug-ins. It shouldn't do that and as you verified it doesn't. Plugins are only to be loaded when necessary.
I am checking whether there is a bug report on this issue.