windows 下用mingw64编译SDL2,为什么不能执行?
按照这个教程来的。
https://www.matsson.com/prog/sdl2-mingw-w64-tutorial.php
运行时提示
程序“main.exe”无法运行: 指定的可执行文件不是此操作系统平台的有效应用程序。所在位置 行:1 字符: 1
+ .\\main.exe
+ ~~~~~~~~~~~。
所在位置 行:1 字符: 1
+ .\\main.exe
+ ~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (:) [], ApplicationFailedException
+ FullyQualifiedErrorId : NativeCommandFailed
我把程序精简一下:
#include <stdio.h>
#include <SDL2/SDL.h>
int main(int argc, char* argv[])
{
/* Initializes the timer, audio, video, joystick,
haptic, gamecontroller and events subsystems */
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
printf("Error initializing SDL: %s\n", "Hello"); //SDL_GetError());
return 0;
}
printf("SDL successfully initialized!\n");
SDL_Quit();
return 0;
}
这样依然不行。
如果去掉SDL部分,程序是能正常执行的。可以printf打印出字符串。
相同目录下要有sdl2.dll吧
或者把sdl2.dll注册到系统dll tomzbj 发表于 2022-9-16 23:30
相同目录下要有sdl2.dll吧
或者把sdl2.dll注册到系统dll
(引用自2楼)
放了的。 增加定义
#define SDL_MAIN_HANDLED
问题解决
页:
[1]