hi, im writing a game engine using C++, SDL and OpenGL. i remembered to link it against SDL.lib, SDLmain.lib, and OpenGL32.lib and to set the runtime library to multithreaded DLL and to include SDL.h and GL/gl.h in every file, but for some reason, the linker still gives me this error:
Quote:
Lobster error LNK2019: unresolved external symbol _SDL_main referenced in function _main
here is the source code to main, which seems to be the problem:
[source lang = 'C++']
// Lobster.cpp : Defines the entry point for the console application.
//
#include "lobster.h"
#include "targa.h"
char gExiting;
int main(int argc, char *argv)
{
LOB_KEYSTATE keystate;
LOB_MOUSESTATE mousestate;
SDL_Event event;
LOB_POINTI resolution;
init();
gExiting = FALSE;
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO |SDL_INIT_JOYSTICK))
{
printf("Error in SDL_INIT(): %s\n", SDL_GetError());
return 0;
}
const SDL_VideoInfo *VideoInfo;
VideoInfo = SDL_GetVideoInfo();
if (!VideoInfo)
{
printf("Error while attempting to call SDL_GetVideoInfo: %s\n", SDL_GetError());
return FALSE;
}
resolution.x = LOB_WIDTH;
resolution.y = LOB_HEIGHT; //TODO: Let user pick the resolution
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
//TODO: Let the user choose to start in a window
if (SDL_SetVideoMode(resolution.x, resolution.y, VideoInfo->vfmt->BitsPerPixel, SDL_OPENGL | SDL_FULLSCREEN) == 0)
{
printf("Error:Call to SDL_SetVideoMode() failed: %s\n", SDL_GetError());
return FALSE;
}
//Main program loop
while (!gExiting)
{
//Input subsystem
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_KEYDOWN:
keystate.prev = keystate.now;
keystate.now.Keys = event.key.keysym.sym;
keystate.now.Mods = event.key.keysym.mod;
keystate.now.IsKeyPressed = TRUE;
HandleKeys(keystate);
break;
case SDL_KEYUP:
keystate.prev = keystate.now;
keystate.now.Keys = event.key.keysym.sym;
keystate.now.Mods = event.key.keysym.mod;
keystate.now.IsKeyPressed = FALSE;
HandleKeys(keystate);
break;
case SDL_MOUSEBUTTONDOWN:
mousestate.prev = mousestate.now;
mousestate.now.xPos = event.button.x;
mousestate.now.yPos = event.button.y;
switch (event.button.button)
{
case SDL_BUTTON_LEFT:
mousestate.now.LeftButton = DOWN;
break;
case SDL_BUTTON_RIGHT:
mousestate.now.RightButton = DOWN;
break;
case SDL_BUTTON_MIDDLE:
mousestate.now.MiddleButton = DOWN;
break;
default:
break;
} //switch (event.button.button)
HandleMouse(mousestate, NULL);
break;
case SDL_MOUSEBUTTONUP:
mousestate.prev = mousestate.now;
mousestate.now.xPos = event.button.x;
mousestate.now.yPos = event.button.y;
switch (event.button.button)
{
case SDL_BUTTON_LEFT:
mousestate.now.LeftButton = UP;
break;
case SDL_BUTTON_RIGHT:
mousestate.now.RightButton = UP;
break;
case SDL_BUTTON_MIDDLE:
mousestate.now.MiddleButton = UP;
break;
} //switch (event.button.button)
HandleMouse(mousestate, NULL);
break;
case SDL_MOUSEMOTION:
mousestate.prev = mousestate.now;
mousestate.now.xPos = event.motion.x;
mousestate.now.yPos = event.motion.y;
mousestate.now.xVel = event.motion.xrel;
mousestate.now.yVel = event.motion.yrel;
HandleMouse(mousestate, NULL);
break;
/* case SDL_BUTTON_WHEELUP:
HandleMouse(mousestate, UP);
break;
case SDL_BUTTON_WHEELDOWN:
HandleMouse(mousestate, DOWN);
break;*/
default:
break;
}
}
}
SDL_Quit();
return TRUE;
}
can someone please help me? thanks in advance for all your help.