I've been having a lot of trouble getting everything working so that I can start developing on Windows, as apposed to Linux, which is what I normally use when coding. I'm having a rather bizarre issue when trying to compile an SDL program. As soon as I include the SDL library, the program refuses to compile, giving me this error:
c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../libmingw32.a<main.o>: In function 'main':
C:\MinGW\msys\1.0\src\mingwrt/../mingw/main.c:73: undefined reference to 'WinMain@16'
collect2: ld returned 1 exist status
I am using MinGW on console.
To give an example, using
gcc -o test main.c
This compiles fine:
#include <stdio.h>
#include <stdlib.h>
int main(int argv, char **argc)
{
printf("Hello, world!\n");
return 0;
}
But as soon as I add #include (even without any SDL functions being called) I get the error mentioned above
Using:
gcc -o test main.c -lSDL
This fails to compile:
#include <stdio.h>
#include <stdlib.h>
#include <SDL/SDL.h>
int main(int argv, char **argc)
{
printf("Hello, world!\n");
return 0;
}
Any help would be greatly appreciated! I read that this was a common issue for people who forget to have a main function, but obviously that's not my issue. I also heard that WinMain is the main function used when dealing with Windows graphical programs, but that's never been an issue for me in the past when I used to develop in Windows more.
I did a little bit of searching for some more information on this error, and I found this page which includes the following informaion:
Try recompiling with those flags above and see whether that makes a difference.