Jump to content
  • Advertisement
Sign in to follow this  

Compiling SDL2 with MinGW through Command line

This topic is 2143 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I am tyring to comile a project with SDL2 through command line with MinGw. I have a run.bat file that looks like so:


g++ -o Game.exe Main/Main.cpp -lmingw32 -lSDL2main -mwindows -lSDL2 
start /d "C:\Users\Mathew Bergen\Documents\Programming\C++\LD Practice" Game.exe

I get these errors:

o): In function `main':
/src/libcrt/crt/main.c:91: undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status

I googled the WInMain@16 error and I found that I needed to add -mwindows to the linking command, but it still does not work. I am on windows 7, Thanks for any help.

Share this post

Link to post
Share on other sites


This will look kind of idiot, but I have seen it happen before when coding on windows with MinGW.

Do your main look like

this :

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

or this:

int main()


Edited by dejaime

Share this post

Link to post
Share on other sites

Ok, I suppose this is worth a try either way.


If I'm thinking about this right, MinGW offers the Win32API as a separate download from gcc, so if you haven't downloaded the Win32API, you might want to check out MinGW on source forge and get that first:



Edited by boogyman19946

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!