喜即時通訊做一個OpenGL項目,但是下載和安裝glut庫文件,它仍然不會編譯,我得到12錯誤C3861後:未找到標識,任何幫助將是巨大的OpenGL的過剩編制問題
#include <windows.h>
#include <gl/gl.h>
void init(void);
void display(void);
void keyboard(unsigned char, int, int);
void resize(int, int);
int is_depth;
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(600, 600);
glutInitWindowPosition(40, 40);
glutCreateWindow("3D World");
init();
glutDisplayFunc(display);
glutKeyboardFunc(keyboard);
glutReshapeFunc(resize);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glEnable(GL_DEPTH_TEST);
is_depth = 1;
glMatrixMode(GL_MODELVIEW);
}
void display(void)
{
if (is_depth)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
else
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glColor3f(0.2f, 0.2f, 0.2f);
glVertex3f(-100.0, 0.0, -100.0);
glColor3f(0.4f, 0.4f, 0.4f);
glVertex3f(-100.0, 0.0, 100.0);
glColor3f(0.6f, 0.6f, 0.6f);
glVertex3f(100.0, 0.0, 100.0);
glColor3f(0.8f, 0.8f, 0.8f);
glVertex3f(100.0, 0.0, -100.0);
glEnd();
}
void keyboard(unsigned char key, int x, int y)
{
switch (key)
{
case 'a':
glTranslatef(5.0, 0.0, 0.0);
break;
case 'd':
glTranslatef(-5.0, 0.0, 0.0);
break;
case 's':
glTranslatef(0.0, 0.0, -5.0);
break;
case 'w':
glTranslatef(0.0, 0.0, 5.0);
break;
}
display();
}
void resize(int width, int height)
{
if(height == 0) height = 1;
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, width/height, 1.0, 400.0);
glTranslatef(0.0, -5.0, -150.0);
glMatrixMode(GL_MODELVIEW);
}
和我的錯誤是
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(17) : error C3861: 'glutInit': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(18) : error C2065: 'GLUT_DOUBLE' : undeclared identifier
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(18) : error C2065: 'GLUT_RGB' : undeclared identifier
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(18) : error C3861: 'glutInitDisplayMode': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(19) : error C3861: 'glutInitWindowSize': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(20) : error C3861: 'glutInitWindowPosition': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(21) : error C3861: 'glutCreateWindow': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(23) : error C3861: 'glutDisplayFunc': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(24) : error C3861: 'glutKeyboardFunc': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(25) : error C3861: 'glutReshapeFunc': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(27) : error C3861: 'glutMainLoop': identifier not found
1>c:\users\riche\documents\visual studio 2008\projects\opengl\opengl\opengl.cpp(97) : error C3861: 'gluPerspective': identifier not found
的要將glut32.dll文件是在我的system32文件夾下
我glut.h文件位於C:\ Program Files文件(x86)的\微軟的Visual Studio 9.0 \ VC \ INC路得
和我glut.lib文件位於C:\ Program Files文件(x86)的\微軟的Visual Studio的lib
UPDATE加入9.0 \ VC \ ,現在我有這些錯誤
error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function _main
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl init(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl init(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl init(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl display(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl display(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl display(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl display(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl display(void)" ([email protected]@YAXXZ)
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl keyboard(unsigned char,int,int)" ([email protected]@[email protected])
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl resize(int,int)" ([email protected]@[email protected])
1>openGL.obj : error LNK2019: unresolved external symbol [email protected] referenced in function "void __cdecl resize(int,int)" ([email protected]@[email protected])
整個一步一步的過程中,以防其他人有同樣的問題在這裏: http://stackoverflow.com/a/8985903/744859 – 2012-01-24 14:24:03