cannot find -lSDLmain

This is the error i am receiving compiling my code. I am using DEV C++. Here is the list of the parameters which i have used.

" -lmingw32 -ISDL -lSDLmain -mwindows -lSDL_mixer -lopengl32 -lglu32 -sdl_Mixer "
This is what the main looks like.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <stdio.h>
#include "Game.h"

     
int main(int argc, char **argv) {
  Game pacman_game=Game();
  if(pacman_game.initialize()) {
    while(pacman_game.update()) {
      pacman_game.draw();

   }
  }
  else 
    printf("Couldn't initialize game.");
}


I have been on this issue for a couple of hours! Searched a lot in google to no avail. Please help! I am running Windows Vista. DEV C++ 4.9.9.2 version.
try compiling with
<...> -lmingw32 -lSDLmain -ISDL <...>
Make sure you followed the instructions here:
http://lazyfoo.net/SDL_tutorials/lesson01/windows/devcpp/index.php

Part of the setup is to place the SDL library files (*.a *.lib) in your MinGW's lib directory.

Good luck!
Thanks Duoas. The link that you provided me with helped me get rid of the "cannot find -lSDLmain" error. Unfortunately now its showing another error which has equally stumped me.

It reads

1
2
3
[Linker error] undefined reference to `WinMain@16'
ld returned 1 exit status 
C:\blahblah\Makefile.win [Build Error]  [pacman.exe] Error 1  


Once again thank you for your timely response. :) I hope you can help me out on this one.
Wild guess:
You don't define main() as
int main(int argc, char **argv) { ... }
Yes, SDL applications require you to declare main() exactly as R0mai indicated.

That's because SDL wants to initialize itself and does so by declaring main() elsewhere in the application, and #defining "main" to a new name that SDL's main() calls...

(I personally think this is a terrible way to initialize, but that makes no difference...)
Thank you everyone. Its finally working now.

The fix to the second issue was as rightly pointed out by Duoas was with the main()

I have added the following code before the main declaration.

#undef main
Why don't you just declare main the way R0mai suggested?
1
2
3
4
5
6
7
#include "SDL.h"

int main( int argc, char **argv )
  {
  // My cool SDL app here
  return 0;
  }
I really wish SDL used a better method for initialization than #defining main.
Topic archived. No new replies allowed.