Can't create executable for running SDL game in windows(error: previous declaration of SDL_main was ...)

Can't create executable for running SDL game in windows(error: previous declaration of SDL_main was ...)

我在 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 mencioned it looks like the problem was that in my program,

int main(int argc, char const *argv[]) 
the argv array was constant which as stated in here 它不会起作用。 所以正确的代码是:


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