QT应用程序在启动时崩溃(c ++窗口)

时间:2013-05-23 20:45:10

标签: c++ qt crash

我的源代码是一个qt应用程序,是由不在我公司的其他人编写的。

我设法使用qt 4.8.4编译代码。我发现原版使用的是qt 4.7.3。

当我运行应用程序时,它在一个qt DLL中启动后就崩溃了。

我正在开发windows7 x64,但目标是x86。我正在使用VS 2012并使用VS 2012编译qt。

我是否需要为QT设置任何环境变量才能正常工作?

我是否需要安装任何其他软件(例如opengl或其他qt继电器的库)?

修改1

崩溃后的堆栈是:

QtOpenGLd4.dll!QGLContextPrivate::extensionFuncs(const QGLContext * ctx) Line 467   C++
    QtOpenGLd4.dll!qt_resolve_glsl_extensions(QGLContext * ctx) Line 257    C++
    QtOpenGLd4.dll!QGLShaderPrivate::create() Line 227  C++
    QtOpenGLd4.dll!QGLShader::QGLShader(QFlags<enum QGLShader::ShaderTypeBit> type, const QGLContext * context, QObject * parent) Line 342  C++
    QtOpenGLd4.dll!QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext * context) Line 191  C++
    QtOpenGLd4.dll!QGLContextGroupResource<QGLEngineSharedShaders>::value(const QGLContext * context) Line 777  C++
    QtOpenGLd4.dll!QGLShaderStorage::shadersForThread(const QGLContext * context) Line 63   C++
    QtOpenGLd4.dll!QGLEngineSharedShaders::shadersForContext(const QGLContext * context) Line 74    C++
    QtOpenGLd4.dll!QGLEngineShaderManager::QGLEngineShaderManager(QGLContext * context) Line 467    C++
    QtOpenGLd4.dll!QGL2PaintEngineEx::begin(QPaintDevice * pdev) Line 2150  C++
    QtGuid4.dll!QPainter::begin(QPaintDevice * pd) Line 1881    C++
    QtGuid4.dll!QPainter::QPainter(QPaintDevice * pd) Line 1508 C++
    myapp.exe!SViewer::paintEvent(QPaintEvent * __formal) Line 187  C++
    QtGuid4.dll!QWidget::event(QEvent * event) Line 8533    C++
    QtOpenGLd4.dll!QGLWidget::event(QEvent * e) Line 4408   C++
    QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 4562    C++
    QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4527  C++
    QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver, QEvent * event) Line 946  C++
    QtCored4.dll!QCoreApplication::sendSpontaneousEvent(QObject * receiver, QEvent * event) Line 234    C++
    QtGuid4.dll!QWidgetPrivate::drawWidget(QPaintDevice * pdev, const QRegion & rgn, const QPoint & offset, int flags, QPainter * sharedPainter, QWidgetBackingStore * backingStore) Line 5598  C++
    QtGuid4.dll!QWidgetPrivate::repaint_sys(const QRegion & rgn) Line 1659  C++
    QtGuid4.dll!QWidgetPrivate::syncBackingStore() Line 1894    C++
    QtGuid4.dll!QWidget::event(QEvent * event) Line 8680    C++
    QtOpenGLd4.dll!QGLWidget::event(QEvent * e) Line 4408   C++
    QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 4562    C++
    QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4527  C++
    QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver, QEvent * event) Line 946  C++
    QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Line 231   C++
    QtCored4.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver, int event_type, QThreadData * data) Line 1570    C++
    QtCored4.dll!qt_internal_proc(HWND__ * hwnd, unsigned int message, unsigned int wp, long lp) Line 496   C++
    user32.dll!75ce62fa()   Unknown
    [Frames below may be incorrect and/or missing, no symbols loaded for user32.dll]    
    user32.dll!75ce6d3a()   Unknown
    user32.dll!75ce6ce9()   Unknown
    user32.dll!75ce77c4()   Unknown
    user32.dll!75ce788a()   Unknown
    QtCored4.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 810    C++
    QtGuid4.dll!QGuiEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1204 C++
    QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 150   C++
    QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 204    C++
    QtGuid4.dll!QDialog::exec() Line 555    C++
    myapp.exe!MainWindow::actionWelcomeDialog() Line 1078   C++
    myapp.exe!MainWindow::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 92  C++
    QtCored4.dll!QMetaCallEvent::placeMetaCall(QObject * object) Line 524   C++
    QtCored4.dll!QObject::event(QEvent * e) Line 1194   C++
    QtGuid4.dll!QWidget::event(QEvent * event) Line 8845    C++
    QtGuid4.dll!QMainWindow::event(QEvent * event) Line 1479    C++
    QtGuid4.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 4562    C++
    QtGuid4.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 4527  C++
    QtCored4.dll!QCoreApplication::notifyInternal(QObject * receiver, QEvent * event) Line 946  C++
    QtCored4.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Line 231   C++
    QtCored4.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver, int event_type, QThreadData * data) Line 1570    C++
    QtCored4.dll!qt_internal_proc(HWND__ * hwnd, unsigned int message, unsigned int wp, long lp) Line 496   C++
    user32.dll!75ce62fa()   Unknown
    user32.dll!75ce6d3a()   Unknown
    user32.dll!75ce6ce9()   Unknown
    user32.dll!75ce77c4()   Unknown
    user32.dll!75ce788a()   Unknown
    QtCored4.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 810    C++
    QtGuid4.dll!QGuiEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 1204 C++
    QtCored4.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 150   C++
    QtCored4.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 204    C++
    QtCored4.dll!QCoreApplication::exec() Line 1218 C++
    QtGuid4.dll!QApplication::exec() Line 3824  C++
    myapp.exe!main(int argc, char * * argv) Line 26 C++
    myapp.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * __formal, int cmdShow) Line 131    C++
    myapp.exe!__tmainCRTStartup() Line 528  C
    myapp.exe!WinMainCRTStartup() Line 377  C
    kernel32.dll!758333aa() Unknown
    ntdll.dll!77d59ef2()    Unknown
    ntdll.dll!77d59ec5()    Unknown

2 个答案:

答案 0 :(得分:1)

我使用Qt 4.8.3和OpenGL在我自己的QT-Application上遇到了同样的问题。

我发现崩溃是由于使用OpenGL绘图引擎造成的。如果OpenGL驱动程序报告它支持OpenGL 2.0,则引擎类型应自动设置为OnegGL2。在我的情况下,这似乎是失败的。

要解决此问题,我在构建QT-Application之前添加以下代码来设置OpenGL首选绘制引擎:

QGL::setPreferredPaintEngine(QPaintEngine::OpenGL);

答案 1 :(得分:0)

好的......这是你的清单:

确保使用MSVS编译器构建,并为win32进行编译。

如果您的应用程序被为mingw或win64构建的dll包围,您可能刚刚输入了“DLL he **”。确保您的应用程序的exe旁边或工作目录(可能是您的源所在的文件夹)中没有任何dll。

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586(v=vs.85).aspx#search_order_for_desktop_applications

现在去检查你的系统和用户环境变量。确保没有您正在构建的某些Qt文件夹的列表。

还要确保Qt Creator或Visual Studio指向您正在构建的Qt版本。

对项目进行构建清理,并重建整个项目。请务必阅读“编译输出”和“构建输出”文件夹。

尝试在调试中构建和运行程序。然后还尝试在发布中构建和运行您的程序。记下应用程序输出和编译输出。

如果你仍然在启动时崩溃,那么在整个代码中开始输入调试语句,以查看它在哪里死亡,或者在调试模式下运行调试版本时断点。例如:qDebug() << Q_FUNC_INFO;位于主要功能的顶部。

当它崩溃时,请记下返回码。在Google中搜索返回代码也可以告诉你很多关于发生了什么的事情。

同时检查程序所依赖的路径。

转到.pro文件中查看您不知道的任何依赖项。

除此之外,您可能需要提供更多信息以获得更多帮助。 :)

希望有所帮助。