Overv
Overv

Reputation: 8519

SDL_main linking issue with VS2010

I've written some basic setup code for an OpenGL application:

#include <Windows.h>
#include <gl/gl.h>
#include <SDL.h>

int main()
{
    SDL_Init( SDL_INIT_VIDEO );

    SDL_Surface* surface = SDL_SetVideoMode( 800, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_OPENGL );
    glViewport( 0, 0, 800, 600 );

    SDL_Event windowEvent;
    while ( true )
    {
        if ( SDL_PollEvent( &windowEvent ) )
        {
            if ( windowEvent.type == SDL_QUIT ) break;
        }

        glClearColor( 1.0f, 0.0f, 0.0f, 1.0f );
        glClear( GL_COLOR_BUFFER_BIT );

        SDL_GL_SwapBuffers();
    }

    SDL_Quit();
    return 0;
}

Unfortunately this fails to link with the following error:

1>SDLmain.lib(SDL_win32_main.obj) : error LNK2001: unresolved external symbol _SDL_main

Linker settings:

http://puu.sh/kVae

Upvotes: 0

Views: 837

Answers (1)

Luchian Grigore
Luchian Grigore

Reputation: 258548

Use main's full signature:

int main(int argc, char *argv[]) 

or

int main(int argc, char **argv) 

or try implementing _SDL_Main instead of main.

Upvotes: 4

Related Questions