loosecannon
loosecannon

Reputation: 7803

undefined reference to `SDL_main'

I am trying to build a project on windows using MinGW and eclipse. I'm using the SDL library but when i try to complie it, I get the error

g++ -Wl,-subsystem,windows -oplikoo.exe src\mouse.o src\camera.o src\Timer.o src\Pegs.o src\Graphics.o src\FPS.o src\Ball.o -lmingw32 -lSDLmain -lSDL.dll -lSDL_image -lSDL_mixer
c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../libSDLmain.a(SDL_win32_main.o): In function `console_main':
/Users/hercules/trunk/SDL-1.2/./src/main/win32/SDL_win32_main.c:315: undefined reference to `SDL_main'

I understand that main has to have the int main(int argc, char *argv[]) signature, and #include <SDL.h> in that file, but it still does not work.

Upvotes: 2

Views: 6437

Answers (3)

Vitor
Vitor

Reputation: 340

This just happend to me. When i started to define main with the args parameters:

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

the compiler error wen away.

Upvotes: 5

TheBuzzSaw
TheBuzzSaw

Reputation: 8826

Scanning over your compilation line there, I noticed you are attempting to link against "SDL.dll" directly. That's not what you want. You should be linking against libSDL.la (provided you are actually using mingw).

Also, I'm not sure if this affects anything here, but I've heard that you are "supposed to" link to "SDL" last.

Upvotes: 2

loosecannon
loosecannon

Reputation: 7803

main.cpp was not in src dir, not being compiled

Upvotes: 3

Related Questions