# SDL installation on MinGW

**URL:** <https://discourse.libsdl.org/t/sdl-installation-on-mingw/19949>\
**Category:** SDL Development\
**Created:** [September 5, 2013, 2:27pm UTC](https://discourse.libsdl.org/t/sdl-installation-on-mingw/19949 "2013-09-05T14:27:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![holyblackcat](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/holyblackcat/32/2121_2.png) [@holyblackcat](https://discourse.libsdl.org/u/holyblackcat)\
**Post date:** [September 5, 2013, 2:27pm UTC](https://discourse.libsdl.org/t/sdl-installation-on-mingw/19949/1 "2013-09-05T14:27:14Z")

</div>

(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](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.

---

<div class="post-metadata">

**Author:** ![Kaifory](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/k/dfb087/32.png) [@Kaifory](https://discourse.libsdl.org/u/Kaifory)\
**Post date:** [September 6, 2013, 2:32am UTC](https://discourse.libsdl.org/t/sdl-installation-on-mingw/19949/2 "2013-09-06T02:32:29Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![Hernan\_Gurmendi](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/h/b77776/32.png) [@Hernan\_Gurmendi](https://discourse.libsdl.org/u/Hernan_Gurmendi)\
**Post date:** [September 6, 2013, 2:35am UTC](https://discourse.libsdl.org/t/sdl-installation-on-mingw/19949/3 "2013-09-06T02:35:49Z")

</div>

Try adding -lmingw32 to the gcc command

2013/9/5 Kaifory \<glissando.sc at [gmail.com](http://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](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)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org](http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org)

---

<div class="post-metadata">

**Author:** ![holyblackcat](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/holyblackcat/32/2121_2.png) [@holyblackcat](https://discourse.libsdl.org/u/holyblackcat)\
**Post date:** [September 6, 2013, 11:05am UTC](https://discourse.libsdl.org/t/sdl-installation-on-mingw/19949/4 "2013-09-06T11:05:48Z")

</div>

> 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!
