Advertisement

SDL and dev-c++

Started by February 23, 2005 07:46 PM
2 comments, last by Stompy9999 20 years ago
I've been reading the cone3d tutorials on SDL and tried to make a simple SDL program. I'm using Dev-C++ as my compiler. In the project options, I typed the following under extra libraries: -lmingw32 -lSDLmain -lSDL Here is the code:


#include <stdio.h>
#include <stdlib.h>

#include <SDL/SDL.h>


int main()
{

    SDL_Surface *screen, *logo;
    bool pause = true;
    SDL_Rect dest;
    
    if(SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0)
       exit(1);
       
    atexit(SDL_Quit);
    
    screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
    
    if(!screen)
       exit(1);
       
    logo = SDL_LoadBMP("intro.bmp");
    
    dest.x = 0;
    dest.y = 0;
    
    SDL_BlitSurface(logo, NULL, screen, &dest);
    
    SDL_Flip(screen);
    
    while(pause)
    {
    
        SDL_Event event;

        while(SDL_PollEvent(&event))
        {
            if(event.type == SDL_QUIT) pause = false;

            if(event.type == SDL_KEYDOWN)
            {
                 if (event.key.keysym.sym == SDLK_ESCAPE) pause = false; 
            }
        }
        
    }
    
    return 0;
    
}


I get the following linker error when I compiled the code:
Quote:
[Linker error] undefined reference to `SDL_main'
What is causing this? Any help would be appreciated.
-----------------------------Play Stompy's Revenge! Now!
did you include SDL.dll in your project? if not, do that.
I pity the fool that uses numerical operators as boolean evaluators!
Advertisement
main must be "int main (int argc, char *argv[])", not just "int main()". Even though the two have no functional difference if you don't use argc or argv, the SDL_main macro doesn't like it.
Oh okay, it works now. Thanks!
-----------------------------Play Stompy's Revenge! Now!

This topic is closed to new replies.

Advertisement