windows - 应用程序无法为 SDL2 应用程序正确启动 0xc00007b
问题描述
我正在使用 Visual Studio 在我的 x64 Windows 10 机器上构建 SDL 应用程序。
我已经按照本教程设置了包含/库/附加依赖项。
一切正常,直到我按照上面的示例添加 SDL_ttf 库作为指导,并将 SDL2_ttf.dll 粘贴到调试文件夹中。
我收到此错误:
“应用程序无法正确启动(0xc000007b)。单击确定关闭应用程序。*
如果我从文件夹中删除 SDL2_ttf.dll,我(仅)收到此错误:
我从此链接下载了 .dll(x64 版本) 。
我的 SDL2.dll 和 SDL2_image.dll(都是 x64)在我只使用这些库时运行我的可执行文件时正常工作。
这里有什么问题?为什么我会收到此错误?
附加信息
我检查了 system32 文件夹(以及整个 Windows 父文件夹),但我没有在那里找到 SDL_ttf.dll。
此外,这是我的调试文件夹的样子:
这是我正在运行的简单代码示例
//Using SDL and standard IO
#include <SDL.h>
#include <SDL_image.h>
#include <stdio.h>
#include <SDL_ttf.h>
//Screen dimension constants
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
SDL_Window* gWindow = nullptr;
SDL_Surface* gScreenSurface = nullptr;
bool init()
{
//Initialization flag
bool success = true;
IMG_Init(IMG_INIT_PNG);
TTF_Init();
//Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
printf("SDL could not initialize! SDL Error: %s\n", SDL_GetError());
success = false;
}
else
{
//Create window
gWindow = SDL_CreateWindow("SDL Tutorial", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN);
if (gWindow == NULL)
{
printf("Window could not be created! SDL Error: %s\n", SDL_GetError());
success = false;
}
else
{
//Initialize PNG loading
int imgFlags = IMG_INIT_PNG;
if (!(IMG_Init(imgFlags) & imgFlags))
{
printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
success = false;
}
else
{
//Get window surface
gScreenSurface = SDL_GetWindowSurface(gWindow);
}
}
}
return success;
}
int main(int argc, char* args[])
{
init();
//Destroy window
SDL_DestroyWindow(gWindow);
//Quit SDL subsystems
SDL_Quit();
return 0;
}
编辑:整理代码
编辑:我知道为什么我会看到这个问题。前几天我将一些库文件复制到了我的 MinGW 文件夹中,我可能已经覆盖了 SDL2 使用的一些重要的 dll 文件(在幕后)。如果我深入了解它,我会发布。同样,我可能会重新安装 MinGW,如果问题得到解决,我会发布更新。
编辑:我终于让它工作了。看起来我的 PATH 中某处有一个不适合我的 x64 应用程序的 dll,而且它不是我上面提到的 3 个 dll 中的任何一个。这就是我的工作文件夹的样子。
解决方案
使用 MinGW 安装管理器重新安装 MinGW 后,程序开始给出不同的错误,指示缺少哪个 dll。SDL 运行时库文件夹包含所有这些文件夹。我复制了它们的 x64 版本,应用程序运行成功。
推荐阅读
- ios - 如何根据 Childviewcontroller(UIViewController 的不同大小)高度更改容器视图(父视图)的高度?
- macos - Mac OSX - 常用命令不起作用
- c# - 更新数据库记录在 c# winforms 和 MSAccess 中不起作用
- google-chrome - 为什么 Chrome 会错误地为我的 JSF 页面资源编写 URL?
- c++ - 如何使用 CImg 加载图像的 CImg 检索色彩空间?
- c# - 通过 PreSignedURL 访问 AWS S3 上的文件时出现异常
- php - 使用带有 codeigniter 的 smtp 向 2 个具有不同消息的收件人发送电子邮件
- xml - 如何可视化 DocBook 文件?
- fullcalendar - 使用 FullCalendar 想要在事件 A 更改时更改事件 B 的属性
- bash - 管道标准输出并为每行添加一些字符