Linker error LNK 2019 with SDL
I have searched the forums for my solution, but the problem has not yet been fixed. I am receiving a LNK 2019 error and I am including all the necessary libraries (sdl.lib and sdlmain.lib) in my project. It is set to use a multi-threaded DLL. The environment has been set up to use the SDL include directories as well. Here''s the error:
error LNK2019: unresolved external symbol _SDL_main referenced in function _main
When I comment out SDL.h, the program compiles (although i can''t run sdl code obviously). Can anyone help?
Thanks,
Justin
//sdl library#include "SDL.h"#include <string>#include <fstream>using namespace std;//#include "Sprite.h"//globals///////////////////////////////////////////////////////////////////////int SCREEN_WIDTH = 800;int SCREEN_HEIGHT = 600;//game states#define GAME_STATE_INITIALIZE 0#define GAME_STATE_MAIN_MENU 1#define GAME_STATE_ACTION 2#define GAME_STATE_VIGNETTE 3#define GAME_STATE_QUIT 4#define GAME_STATE_EXIT 5//MAIN////////////////////////////////////////////////////////////////////////void main(){ //display surface SDL_Surface* g_pDisplaySurface = NULL; //bitmap surface SDL_Surface* g_pBitmapSurface = NULL; //event structure SDL_Event g_Event; //source and destination rectangles SDL_Rect g_SrcRect,g_DstRect; //clipping rectangle SDL_Rect g_ClipRect; //initialize SDL if (SDL_Init(SDL_INIT_VIDEO)==-1) { //error initializing SDL //report the error fprintf(stderr,"Could not initialize SDL!\n"); //end the program exit(1); } else { //SDL initialized //report success fprintf(stdout,"SDL initialized properly!\n"); //set up to uninitialize SDL at exit atexit(SDL_Quit); } //create windowed environment g_pDisplaySurface = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,0,SDL_ANYFORMAT); //error check if (g_pDisplaySurface == NULL) { //report error fprintf(stderr,"Could not set up display surface!\n"); //exit the program exit(1); } //set up the clipping rectangle g_ClipRect.x=32; g_ClipRect.y=32; g_ClipRect.w=SCREEN_WIDTH-64; g_ClipRect.h=SCREEN_HEIGHT-64; //set the clip rect SDL_SetClipRect(g_pDisplaySurface,&g_ClipRect); //initial game state int game_state = GAME_STATE_INITIALIZE; //quit the game? bool quit = false; //make the game run until it's over and all resources have been deallocated while(!quit) { switch(game_state) { //game state initialize case GAME_STATE_INITIALIZE: { game_state = GAME_STATE_MAIN_MENU; break; } //game state main menu case GAME_STATE_MAIN_MENU: { game_state = GAME_STATE_ACTION; break; } //game state action case GAME_STATE_ACTION: { //Sprite mysp("test.txt", g_pDisplaySurface); //mysp.drawSprite(); break; } //game state vignette case GAME_STATE_VIGNETTE: { game_state = GAME_STATE_ACTION; break; } //game state quit case GAME_STATE_QUIT: { //clean up game_state = GAME_STATE_EXIT; break; } //game state exit case GAME_STATE_EXIT: { quit = true; break; } } }
[edited by - mrtuti_17 on June 3, 2004 10:16:29 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement