在Win10上用VS2015编译的C++ SDL2程序中调试加载时间错误 [英] Debugging load time error in C++ SDL2 program compiled with VS2015 on Win10

查看:28
本文介绍了在Win10上用VS2015编译的C++ SDL2程序中调试加载时间错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 2015 在 64 位 Windows 10 上使用 SDL2 在 C++ 中编写一个项目.我最近购买了一台新的 Windows 10 笔记本电脑并从 github 克隆了我的项目.我的项目编译正确,但运行时出现以下错误:

<块引用>

应用程序无法正确启动 (0xc000007b).单击确定"关闭应用程序.

根据我目前的研究,这个错误通常是由加载不兼容的 DLL 引起的,例如64 位版本而不是 32 位版本.到目前为止我发现的建议包括:

  • 检查我使用的是 32 位版本的 SDL2 DLL
  • 安装/重新安装 x86 版本的 Visual C++ Redistributable for Visual Studio 2015
  • 使用

    Dependency Walker 分析结果

    在那之后,分析器冻结并且永远不会继续.请注意,SDL 组件和 VC 运行时加载正常.

    程序在我的两台旧机器上正确编译和加载,一台运行 32 位 Windows 7,另一台运行 64 位 Windows 10.

    现在是实际问题.我可以采取哪些其他步骤来调试此崩溃?还是有人从我提供的信息中看出我做错了什么?

    相关问题:

    • 此时,和以前一样,Dependency Walker 冻结.我仍然完全迷失了方向,感觉自己离确定问题的原因还差得远.

      解决方案

      我觉得自己非常愚蠢,但我终于弄清楚了真正的问题.我正在使用 SDL 字体库 SDL2_ttf,我只是没有将 zlib.dll 从 SDL2_ttf lib 目录复制到我的构建目录中.我不明白为什么错误消息如此神秘;在过去,缺少的 DLL 给了我一个有用的foo.dll is missing"错误消息.

      无论如何,谢谢大家的帮助.至少我学到了一个有用的教训:在怀疑更复杂的问题之前,始终确保所有必需的 DLL 都存在.

      I'm writing a project in C++ with SDL2 on 64-bit Windows 10 using Visual Studio 2015. I recently purchased a new Windows 10 laptop and cloned my project from github. My project compiles correctly, but I get the following error when I run it:

      The application was unable to start correctly (0xc000007b). Click OK to close the application.

      Based on my research so far, this error is usually caused by loading an incompatible DLL, e.g. a 64-bit version instead of 32-bit. Suggestions I've found so far include:

      • Checking that I'm using the 32-bit versions of the SDL2 DLLs
      • Installing/reinstalling the x86 version of the Visual C++ Redistributable for Visual Studio 2015
      • Using Dependency Walker to troubleshoot which DLL is failing

      My project is set to build for Win32, and I've ensured that I'm using the 32-bit versions of all DLLs I'm explicitly linking (libfreetype-6, libpng16-16, SDL2, SDL2_image, SDL2_mixer, and SDL2_ttf). I have confirmed that the x86 VC++ Redistributable is installed on my machine.

      Finally, I've attempted to use Dependency Walker to determine what DLL might be causing the problem (although I've read caveats that Dependency Walker has a lot of false positives). These were the results:

      Dependency Walker static analysis

      Dependency Walker profiling results

      After that point, the profiler freezes and never continues. Note that the SDL components and the VC runtime are loading without error.

      The program compiles and loads correctly on my two older machines, one running 32-bit Windows 7 and one running 64-bit Windows 10.

      Now for the actual question. What other steps can I take to debug this crash? Or does anyone see from the information I've provided what I'm doing wrong?

      Related questions:

      Edit:

      As rflobao suggested, I was using the 64-bit version of Dependency Walker on a 32-bit exe. Here is the new output of my profiling run:

      At this point, as before, Dependency Walker freezes. I'm still totally lost and don't feel like I'm any closer to being able to determine what's causing the problem.

      解决方案

      I feel profoundly dumb, but I finally figured out the real problem. I'm using the SDL font library SDL2_ttf, and I simply hadn't copied zlib.dll from the SDL2_ttf lib directory into my build directory. I don't understand why the error message was so cryptic; in the past missing DLLs have given me a helpful "foo.dll is missing" error message.

      Anyway, thank you all for your help. At least I've learned a useful lesson: always make sure all the required DLLs are present before suspecting a more complex problem.

      这篇关于在Win10上用VS2015编译的C++ SDL2程序中调试加载时间错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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