QSqlDatabase hello world application fails to debug

147 views Asked by At

I'm attempting a QSqlDatabase hello world application using PostgreSQL. My environment is as follows: Windows 7 64-bit, Qt 4.8.2, PostgreSQL 9.0.13. The following code compiles, but will not debug, i.e. when I place a break on the QSqlDatabase::drivers() line, but the code exits with an exception. The application runs as expected when I comment out this line. Any suggestions?

#include <QApplication>
#include <QMainWindow>
#include <QtSql/QtSql>
#include <QtSql/QSqlDatabase>

int main(int argc, char *argv[])
{
    QApplication prog(argc, argv);
    QMainWindow *mainWin = new QMainWindow;
    QStringList drvlst = QSqlDatabase::drivers();  // <-- problem!
    mainWin->show();

    return prog.exec();
}
1

There are 1 answers

0
soulia On BEST ANSWER

Another example of DLL hell and how Dependency Walker can be a great tool for diagnosing potential bugs of this nature. Again, in this case, the linker was traversing the PATH environment variable to find QTSQLD4.DLL library dependencies. The linker found the openVPN SSLEAY32.DLL (which is actually 64 bit) instead of the postgreSQL version of SSLEAY32.DLL. Moving the openVPN url to the end of the PATH environment variable resolved this problem.