QSqlDatabase hello world应用程序无法调试(QSqlDatabase hello world application fails to debug)

编程入门 行业动态 更新时间:2024-10-24 16:33:02
QSqlDatabase hello world应用程序无法调试(QSqlDatabase hello world application fails to debug)

我正在尝试使用PostgreSQL的QSqlDatabase hello world应用程序。 我的环境如下:Windows 7 64位,Qt 4.8.2,PostgreSQL 9.0.13。 下面的代码编译,但不会调试,即当我在QSqlDatabase :: drivers()行中放置一个中断,但代码退出时有异常。 当我注释掉这一行时,应用程序按预期运行。 有什么建议么?

#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(); }

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(); }

最满意答案

DLL地狱的另一个例子以及Dependency Walker如何成为诊断此类潜在错误的绝佳工具。 同样,在这种情况下,链接器遍历PATH环境变量以查找QTSQLD4.DLL库依赖项。 链接器找到了openVPN SSLEAY32.DLL(实际上是64位)而不是SSLEAY32.DLL的postgreSQL版本。 将openVPN url移动到PATH环境变量的末尾解决了这个问题。

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.

更多推荐

本文发布于:2023-04-28 01:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1329658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   world   QSqlDatabase   debug   fails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!