Public Group

# 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.

## 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
pause
start /d "C:\Users\Mathew Bergen\Documents\Programming\C++\LD Practice" Game.exe


I get these errors:

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/lib/libmingw32.a(main.
o): In function main':
e:\p\giaw\src\pkg\mingwrt-4.0.3-1-mingw32-src\bld/../mingwrt-4.0.3-1-mingw32-src
/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 on other sites

Hi.

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

this :

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

or this:

int main()

?

Edited by dejaime

##### Share on other sites

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

http://sourceforge.net/projects/mingw/files/MinGW/Base/w32api/w32api-4.0.3/

Edited by boogyman19946

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 9
• 15
• 9
• 11