c - Undefined reference to WinMain@16 when using SDL -
i've been having lot of trouble getting working can start developing on windows, apposed linux, use when coding. i'm having rather bizarre issue when trying compile sdl program. include sdl library, program refuses compile, giving me 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 'winmain@16' collect2: ld returned 1 exist status
i using mingw on console.
to give 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 add #include (even without sdl functions being called) error mentioned above
using:
gcc -o test main.c -lsdl
this fails compile:
#include <stdio.h> #include <stdlib.h> #include <sdl/sdl.h> int main(int argv, char **argc) { printf("hello, world!\n"); return 0; }
any appreciated! read common issue people forget have main function, that's not issue. heard winmain main function used when dealing windows graphical programs, that's never been issue me in past when used develop in windows more.
i did little bit of searching more information on error, , found this page includes following informaion:
the trick in getting compile add include path (eg: -i../sdl/include), linker path (eg: -l../sdl/lib), , adding libraries in right order. use:
-lmingw32 -lsdlmain -lsdl
also, don't forget add -mwindows flag, if ide doesn't add automatically (in addition whatever other libraries want link). if don't put them in right order, you'll linker error complaining missing symbol winmain@16.
try recompiling flags above , see whether makes difference.
Comments
Post a Comment