OpenGL程序编译后可能出现如下错误:
Linking...
OpenGL.obj : error LNK2001: unresolved external symbol _gluPerspective@32
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glHint@8
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glDepthFunc@4
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glClearDepth@8
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glShadeModel@4
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
OpenGL.obj : error LNK2001: unresolved external symbol __imp__glClear@4
OpenGL.obj : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4
OpenGL.obj : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8
OpenGL.obj : error LNK2001: unresolved external symbol __imp__wglCreateContext@4
VC中操作如下:Project-> Settings,然后单击LINK标签。在"Object/Library Modules"选项中的开始处(在 kernel32.lib 前)增加 OpenGL32.lib GLu32.lib GLaux.lib 后单击OK按钮就行了哈。
或者在代码中(#include<...>下面)添加
# pragma comment( lib,"opengl32.lib");
# pragma comment( lib,"glu32.lib");
# pragma comment (lib,"glaux.lib");