我最近在新计算机上安装了SDL和VS 2010,并且我的测试应用程序出现问题。这里是代码:SDL发生LNK 2019错误
#include <SDL.h>
#include <SDL_opengl.h>
#undef main
int INIT_SDL_OPENGL()
{
if (SDL_Init(SDL_INIT_EVERYTHING) != 0)
{
return 1;
}
SDL_SetVideoMode(640, 360, 32, SDL_OPENGL);
SDL_WM_SetCaption("Skeleton Example", NULL);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
return 0;
}
void EndQuitly()
{
SDL_Quit();
exit(0);
}
int main(int argc, char **argv)
{
INIT_SDL_OPENGL();
glBegin(GL_LINES);
glVertex2f(360, 180);
glVertex2f(640, 360);
glEnd();
EndQuitly();
return 0;
}
,并且错误是:
error LNK1120: 4 unresolved externals C:\Users\einat\Documents\Visual Studio 2010\Projects\SkeletonOpenGLExample.c\Debug\SkeletonOpenGLExample.exe 1 SkeletonOpenGLExample error LNK2019: unresolved external symbol _SDL_Init referenced in function "int __cdecl INIT_SDL_OPENGL(void)" ([email protected]@YAHXZ) C:\Users\einat\Documents\Visual Studio 2010\Projects\SkeletonOpenGLExample.c\SkeletonOpenGLExample.c\testSDL.obj SkeletonOpenGLExample error LNK2019: unresolved external symbol _SDL_Quit referenced in function "void __cdecl EndQuitly(void)" ([email protected]@YAXXZ) C:\Users\einat\Documents\Visual Studio 2010\Projects\SkeletonOpenGLExample.c\SkeletonOpenGLExample.c\testSDL.obj SkeletonOpenGLExample error LNK2019: unresolved external symbol _SDL_SetVideoMode referenced in function "int __cdecl INIT_SDL_OPENGL(void)" ([email protected]@YAHXZ) C:\Users\einat\Documents\Visual Studio 2010\Projects\SkeletonOpenGLExample.c\SkeletonOpenGLExample.c\testSDL.obj SkeletonOpenGLExample error LNK2019: unresolved external symbol _SDL_WM_SetCaption referenced in function "int __cdecl INIT_SDL_OPENGL(void)" ([email protected]@YAHXZ) C:\Users\einat\Documents\Visual Studio 2010\Projects\SkeletonOpenGLExample.c\SkeletonOpenGLExample.c\testSDL.obj SkeletonOpenGLExample
我已经看过了几个教程,跟着所有的链接指示,但如果没有他们似乎工作。
在此先感谢(抱歉,我无法弄清楚如何让正确格式化
您似乎没有链接到SDL。 – Angew 2013-05-07 07:20:46
您与SDL图书馆_do_链接,不是吗? – 2013-05-07 07:20:47
右键单击项目,然后选择属性>链接器>输入:查看“附加依赖关系”条目,您是否看到列出的SDL .lib文件? – JBL 2013-05-07 07:25:06