SDL_main与VS2010的链接问题

时间:2012-03-15 20:32:18

标签: c++ visual-studio-2010 sdl

我为OpenGL应用程序编写了一些基本的设置代码:

#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;
}

不幸的是,这无法链接以下错误:

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

链接器设置:

http://puu.sh/kVae

1 个答案:

答案 0 :(得分:4)

使用main的完整签名:

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

int main(int argc, char **argv) 

或尝试实施_SDL_Main而不是main