SDL installation on MinGW

(I’m not from english-speaking country, so I’m sorry for any spelling mistakes)

Windows 7 x64.
I’m trying to install SDL on MinGW.

I downloaded SDL from here (http://www.libsdl.org/download-2.0.php) (SDL2-devel-2.0.0-mingw.tar.gz link),
then I copied contents of SDL2-2.0.0/x86_64-w64-mingw32/bin into MinGW/bin,
contents of SDL2-2.0.0/x86_64-w64-mingw32/include into MinGW/include and contents of SDL2-2.0.0/x86_64-w64-mingw32/lib into MinGW/lib.

When I try to compile anything that contains “#include <SDL2\SDL.h>” using "cc test.c -lSDL2main -lSDL2 -mwindows"
I getting “unidefined reference to WinMain at 16” and “undefined reference” to all SDL functions I used.

holyblackcat wrote:

(I’m not from english-speaking country, so I’m sorry for any spelling mistakes)

Windows 7 x64.
I’m trying to install SDL on MinGW.

I downloaded SDL from here (http://www.libsdl.org/download-2.0.php) (SDL2-devel-2.0.0-mingw.tar.gz link),
then I copied contents of SDL2-2.0.0/x86_64-w64-mingw32/bin into MinGW/bin,
contents of SDL2-2.0.0/x86_64-w64-mingw32/include into MinGW/include and contents of SDL2-2.0.0/x86_64-w64-mingw32/lib into MinGW/lib.

When I try to compile anything that contains “#include <SDL2\SDL.h>” using "cc test.c -lSDL2main -lSDL2 -mwindows"
I getting “unidefined reference to WinMain at 16” and “undefined reference” to all SDL functions I used.

Hello, I was recently having the same problem as you. You need to take the files from:
SDL2-2.0.0/i686-w64-mingw32 instead of SDL2-2.0.0/x86_64-w64-mingw32 as the x86_64 one is for 32bit systems.

Try adding -lmingw32 to the gcc command

2013/9/5 Kaifory <glissando.sc at gmail.com>> **

holyblackcat wrote:

(I’m not from english-speaking country, so I’m sorry for any spelling
mistakes)

Windows 7 x64.
I’m trying to install SDL on MinGW.

I downloaded SDL from here http://www.libsdl.org/download-2.0.php(SDL2-devel-2.0.0-mingw.tar.gz link),
then I copied contents of SDL2-2.0.0/x86_64-w64-mingw32/bin into MinGW/bin,
contents of SDL2-2.0.0/x86_64-w64-mingw32/include into MinGW/include and
contents of SDL2-2.0.0/x86_64-w64-mingw32/lib into MinGW/lib.

When I try to compile anything that contains “#include **” using "cc
test.c -lSDL2main -lSDL2 -mwindows"
I getting “unidefined reference to WinMain at 16” and "undefined reference"
to all SDL functions I used.

Hello, I was recently having the same problem as you. You need to take the
files from:
SDL2-2.0.0/i686-w64-mingw32 instead of SDL2-2.0.0/x86_64-w64-mingw32 as
the x86_64 one is for 32bit systems.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello, I was recently having the same problem as you. You need to take the files from:
SDL2-2.0.0/i686-w64-mingw32 instead of SDL2-2.0.0/x86_64-w64-mingw32 as the x86_64 one is for 32bit systems.

Try adding -lmingw32 to the gcc command

Thank you guys! It’s working perfectly now!