gpt4 book ai didi

无法创建用于在 Windows 中运行 SDL 游戏的可执行文件(错误 : previous declaration of SDL_main was . ..)

转载 作者:太空宇宙 更新时间:2023-11-04 04:11:09 25 4
gpt4 key购买 nike

我在 ubuntu 中使用 atom 编辑器创建了一个带有 SDL2 库的游戏,并使用以下代码创建了一个 makefile 进行编译:

game: main.c LoadGame.c Events.c CreateTex.c CollisionDetection.c Render.c gameStatus.c    gcc main.c LoadGame.c Events.c CreateTex.c CollisionDetection.c Render.c gameStatus.c -w -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -o game -lm -I.

现在我想创建一个 .exe,所以我创建了这个 makefile:

game: main.c LoadGame.c Events.c CreateTex.c CollisionDetection.c Render.c gameStatus.c    i686-w64-mingw32-gcc main.c LoadGame.c Events.c CreateTex.c CollisionDetection.c Render.c gameStatus.c -w -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -o game.exe -lm -I.

但它给出了这个错误:

    In file included from /usr/i686-w64-mingw32/include/SDL2/SDL.h:32:0,                     from main.c:2:    main.c:8:5: error: conflicting types for ‘SDL_main’     int main(int argc, char const *argv[]){         ^    /usr/i686-w64-mingw32/include/SDL2/SDL_main.h:117:39: note: previous declaration of ‘SDL_main’ was here     tern C_LINKAGE SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]);                                         ^~~~~~~~    makefile:5: recipe for target 'game' failed    make: *** [game] Error 1

所以我需要一些帮助,以便我可以从我的源代码创建一个 .exe 文件以在 Windows 中运行它,同时

最佳答案

好吧,作为keltar提到看起来问题出在我的程序中,

int main(int argc, char const *argv[]) 
argv 数组是常量,如 here 中所述它不会工作。所以正确的代码应该是:

    int main(int argc, char *argv[])

关于无法创建用于在 Windows 中运行 SDL 游戏的可执行文件(错误 : previous declaration of SDL_main was . ..),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57184191/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com