如何在 main() 之前调试程序崩溃 [英] How to debug program crashing before main()

查看:45
本文介绍了如何在 main() 之前调试程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 windows 8.1 上使用带有 Visual Studio 2015 套件的 QtCreator 来构建我在 Linux 上开发和测试的程序,在 linux 上它可以正常工作,但在 windows 上它只是立即崩溃,我不知道该看什么

I'm using QtCreator with the visual studio 2015 kit on windows 8.1 to build a program I developed and tested on Linux, on linux it works correctly, but on windows it's just crashing immediately, and I have no idea what to look for.

除了我使用的 QT 之外,唯一的外部库是 opengl 和 glew,所以我认为不是这些.

The only external libraries, aside from QT I'm using are opengl and glew, so I don't think it's those.

是否有任何已知可以在 GNU C++ 中工作但在 MSVC 中立即崩溃的东西?

Is there anything that's known to work in GNU C++ but crash immediately in MSVC?

推荐答案

通常这种崩溃与您的程序完全无关.这是一个外部库链接问题.我最近在使用 OpenSplice DDS 库时遇到了这个问题.我链接到一个在任何开始之前导致分段错误的库.我通过 1 对 1 链接预编译库解决了这个问题,并检查每个库是否修复了程序.

Usually this kind of crashes have absolutely nothing to do with your program. It's an external library linking issue. I had this issue recently with the OpenSplice DDS library. I linked to a library that caused a segmentation fault before anything started. I resolved the issue by linking the pre-compiled libraries 1-by-1, and check each if that fixes the program.

我建议您做的是: 逐渐删除您要链接的库和资源,直到您的程序启动并从 main().

What I recommend you to do is: Remove the libraries and resources you're linking to gradually, until your program starts and prints "Hello world" from the first line of main().

另一种方法是,创建一个新的空程序,并链接您在程序中使用的相同资源.这更容易,因为它不涉及修改您的程序.

Another way to go is, make a new empty program, and link the same resources you're using in your program. This is easier, as it doesn't involve modifying your program.

这篇关于如何在 main() 之前调试程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆