Compiling SDL2 with MinGW through Command line

Started by
1 comment, last by boogyman19946 10 years, 4 months ago

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.

Advertisement

Hi.

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()

?

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:

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

Yo dawg, don't even trip.

This topic is closed to new replies.

Advertisement