I’m a new to OpenGL, I’m follow a book named “OpenGL SuperBible” by R.S.Wright,JR. I followed the instruction to set up my system(contains GLUT) and tried a very simply program:
//Program Begins:
#include <windows.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
void RenderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void SetupRC(void)
{
glClearColor(0.0f,0.0f,1.0f,1.0f);
}
int main(void)
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow(“Simple”);
glutDisplayFunc(RenderScene);
SetupRC();
glutMainLoop();
return 0;
}
//Program End
When I try to compile it, It always show me this:
--------------------Configuration: Lesson01 - Debug--------------------
Compiling…
Lesson01.cpp
In file included from Lesson01.cpp:2:
C:\MinGWStudio\MinGW\include\GL\glut.h:58: warning: ignoring #pragma comment
C:\MinGWStudio\MinGW\include\GL\glut.h:66: warning: ignoring #pragma comment
C:\MinGWStudio\MinGW\include\GL\glut.h:67: warning: ignoring #pragma comment
C:\MinGWStudio\MinGW\include\GL\glut.h:68: warning: ignoring #pragma comment
C:\MinGWStudio\MinGW\include\GL\glut.h:76: warning: ignoring #pragma warning
C:\MinGWStudio\MinGW\include\GL\glut.h:77: warning: ignoring #pragma warning
C:\MinGWStudio\MinGW\include\GL\glut.h:486: warning: void glutInit_ATEXIT_HACK(int*, char**)' defined but not used C:\MinGWStudio\MinGW\include\GL\glut.h:549: warning:
int
glutCreateMenu_ATEXIT_HACK(void (*)(int))’ defined but not used
Lesson01.o - 0 error(s), 8 warning(s)
And when I try to execute it, There are some errors:
--------------------Configuration: Lesson01 - Debug--------------------
Linking…
C:\cpp\HeNe’s OpenGL Lesson\Lesson01\Debug\Lesson01.o(.text+0x1c): In function glutInit_ATEXIT_HACK': C:\MinGWStudio\MinGW\include\GL\glut.h:486: undefined reference to
__glutInitWithExit@12’
C:\cpp\HeNe’s OpenGL Lesson\Lesson01\Debug\Lesson01.o(.text+0x3d): In function glutCreateWindow_ATEXIT_HACK': C:\MinGWStudio\MinGW\include\GL\glut.h:503: undefined reference to
__glutCreateWindowWithExit@8’
C:\cpp\HeNe’s OpenGL Lesson\Lesson01\Debug\Lesson01.o(.text+0x5d): In function glutCreateMenu_ATEXIT_HACK': C:\MinGWStudio\MinGW\include\GL\glut.h:549: undefined reference to
__glutCreateMenuWithExit@8’
C:\cpp\HeNe’s OpenGL Lesson\Lesson01\Debug\Lesson01.o(.text+0xe4): In function main': C:\cpp\HeNe's OpenGL Lesson\Lesson01\Lesson01.cpp:19: undefined reference to
glutInitDisplayMode@4’
C:\cpp\HeNe’s OpenGL Lesson\Lesson01\Debug\Lesson01.o(.text+0x102):C:\cpp\HeNe’s OpenGL Lesson\Lesson01\Lesson01.cpp:21: undefined reference to glutDisplayFunc@4' C:\cpp\HeNe's OpenGL Lesson\Lesson01\Debug\Lesson01.o(.text+0x10f):C:\cpp\HeNe's OpenGL Lesson\Lesson01\Lesson01.cpp:25: undefined reference to
glutMainLoop@0’
Lesson01.exe - 6 error(s), 0 warning(s)
I’m using MinGW in Windows XP sp2, the GLUT version is 3.7.6 downloaded from this site. I really don’t know why get these errors, I’m new to OpenGL, before that, I only learned C++(NOT VC++, I’ve no experience about that.) and some Java programming. Should I learn something else? Please help me, thank you very much.