Help to compile

Hi! I’m newbie on this list and i cant compile my c++/SDL program under
windows… I use:
gcc SDL_teste.cpp -lSDLmain -lSDL -mwindows
and get the error msg:
"undefined reference to "WinMain at 16"
the code:-------------------------------------------------------------
#include <stdio.h>
#include “SDL/SDL.h”
// include the SDL headers you put in /mingw/include/SDL/

int main(int argc, char *argv[]) {
// with SDL, you need the argc and argv parameters

printf(“Hello world\n”);
// with SDL, anything you printf will get printed to the
// file stdout.txt in the current directory, not to the screen
}

thanks all!
Igor Castro

There are several errors here:

  1. You don’t have warnings turned on. For current GCCs, use ‘-W -Wextra’, for
    older ones (up to 3.4 or so) use ‘-W -Wall’.
  2. When you are compiling C++ code, use the C++ compiler, i.e. use 'g++'
    instead of ‘gcc’.
  3. To compile portably, just use the output of the ‘sdl-config’ program for
    compiler and linker flags. This should automatically get it right.

Also, in your program, don’t include <SDL/SDL.h> but just “SDL.h”.
Again, ‘sdl-config’ will do the rest for you.

UliOn Sunday 20 May 2007 18:00:49 Igor Castro wrote:

Hi! I’m newbie on this list and i cant compile my c++/SDL program under
windows… I use:
gcc SDL_teste.cpp -lSDLmain -lSDL -mwindows

Igor Castro wrote:

Hi! I’m newbie on this list and i cant compile my c++/SDL program under
windows… I use:
gcc SDL_teste.cpp -lSDLmain -lSDL -mwindows
and get the error msg:
"undefined reference to “WinMain at 16”

Try adding -lmingw32