我为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
链接器设置:
答案 0 :(得分:4)
使用main
的完整签名:
int main(int argc, char *argv[])
或
int main(int argc, char **argv)
或尝试实施_SDL_Main
而不是main
。