Error: "Multiple Definition of Main"

Yo, guys, have you seen this before?

here’s some info:

I’m running Dev C++ 4.9.8.0, but my roommate says he’s seen this error
on MSVC++ 6 too, so don’t stop and say you can’t help me, if you’ve seen
this before!

Here’s the compile log:

Compiler: Default compiler
Building Makefile: “D:\Desktop\Testoron2\Makefile.win"
Executing make…
make.exe -f “D:\Desktop\Testoron2\Makefile.win” all
g++.exe main.o -o “Testoron2.exe” -L"D:/Dev-Cpp/lib” -lmingw32 -lSDLmain
-lSDL -mwindows

D:/Dev-Cpp/lib\SDLmain.lib(./Release/SDL_main.obj)(.text+0x0):C:\SDL\SDL12\Src\M:
multiple definition of main' D:/Dev-Cpp/lib/libmingw32.a(main.o)(.text+0x0):main.c: first defined here D:/Dev-Cpp/lib\SDLmain.lib(./Release/SDL_main.obj.b)(.text+0x55):C:\SDL\SDL12\Src\M: undefined reference to_alloca_probe’
D:/Dev-Cpp/lib\SDLmain.lib(./Release/SDL_main.obj.b)(.text+0xf6):C:\SDL\SDL12\Src\M:
undefined reference to _alloca_probe' D:/Dev-Cpp/lib\SDLmain.lib(./Release/SDL_main.obj.b)(.text+0x139):C:\SDL\SDL12\Src\M: undefined reference to_alloca_probe’

make.exe: *** [Testoron2.exe] Error 1

Execution terminated

Here’s the code:

(this compiles and runs successfully in VC++ 6)

#include <SDL/SDL.h>
#include <stdio.h>
#include <conio.h>

void cleanup()
{
SDL_Quit();
}

int main( int argc, char* argv[] )
{
if (SDL_Init( SDL_INIT_VIDEO) < 0)
{
return 0;
}

SDL_Surface *screen;

/* Initialize the SDL library */
if (SDL_Init(SDL_INIT_VIDEO) < 0)
{
fprintf(stderr, “Couldn’t initialize SDL: %s\n”, SDL_GetError());
cleanup();
return 1;
}

/*

  • Initialize the display in a 640x480 8-bit palettized mode,
  • requesting a software surface
    */
    screen = SDL_SetVideoMode(1024, 768, 24, SDL_SWSURFACE);
    if ( screen == NULL ) {
    fprintf(stderr, “Couldn’t set 1024x768x24 video mode: %s\n”,
    SDL_GetError());
    cleanup();
    return 1;
    }

SDL_Surface *image;

image = SDL_LoadBMP(“gfx/characters/McKay.bmp”);
if (image == NULL)
{
fprintf(stderr, “Couldn’t load %s: %s\n”, “McKay.bmp”, SDL_GetError());
return 1;
}

SDL_SetColorKey(image, SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 0,
120, 248));

SDL_Rect McKaylocation;
McKaylocation.x = 200;
McKaylocation.y = 200;
SDL_Rect OldLocation;

if(SDL_BlitSurface(image, NULL, screen, &McKaylocation) < 0)
fprintf(stderr, “BlitSurface error: %s\n”, SDL_GetError());

SDL_UpdateRect(screen, McKaylocation.x, McKaylocation.y, McKaylocation.x

  • image->w, McKaylocation.y + image->h);

SDL_Event event;
bool done;
done = false;
while(done == false)
{
OldLocation = McKaylocation;
SDL_PollEvent(&event);
switch(event.type)
{
case SDL_KEYDOWN:
done = true;
break;

case SDL_QUIT:
done = true;
break;
}
SDL_Rect slice;
slice.x = 4;
slice.y = 0;
slice.w = 2;
slice.h = 16;
SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
if(SDL_BlitSurface(image, &slice, screen, &McKaylocation) < 0)
fprintf(stderr, “BlitSurface error: %s\n”, SDL_GetError());
}

/* Free the allocated BMP surface */
SDL_FreeSurface(image);

cleanup();
return 0;
}

Thanks in advance,

  • KMar