1
votes

I've created a game with SDL2 library in ubuntu with the atom editor, and for compiling created a makefile with this code:

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.

And now I want to create an .exe so I created this 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.

but it gives this error:


    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


So I'd like some help so I can create a single .exe file from my sourcecode to run it in windows,while

1
char** and char const ** are different types. Write your main exactly as int main(int argc, char *argv[]) (or char **argv as these types are equivalent here). It is answered in SDL windows FAQkeltar
Okay Thank you so much!,new errors, linker errors arrived, but I'll search those up and create a new thread if necessary Thank you!(Btw I'm new in stack overflow how do I close a thread?)André Páscoa
As there is no answer here you write one and accept it. I'd argue lazyfoo tutorials are not good for C as it silently makes some C++ assumptions.keltar
On MinGW you need -lmingw32 -lSDL2main -lSDL2 rather than just -lSDL2.HolyBlackCat
Thank you HolyBlackCat! had a bit time off and was great to have my problem resolved when I got back.André Páscoa

1 Answers

0
votes

Okay so, as keltar mencioned it looks like the problem was that in my program,

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

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