GLUT doesn't work.

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)

void SetupRC(void)

int main(void)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);



return 0;
//Program End
When I try to compile it, It always show me this:
--------------------Configuration: Lesson01 - Debug--------------------
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--------------------
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 toglutInitDisplayMode@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 toglutMainLoop@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.

Hi, i was just experiencing same problem and after I spent 2 hours :slight_smile: by browsing and trying to find a way. I am using DevCpp and finally this is what helped.

try to put this line directly to code:


and content of my linker is:
-lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32

try to change it similarly if the first trick does not work. keep it in same order.

I hope, this will help. I tried your code and it was working, actually.

Thanks a lot. I tried your suggestion yesterday, I’m sorry but it still doesn’t work well, but it’s only 6 errors now. I tried this program in VC++ 6.0, every thing goes fine, ~~~ but I doesn’t like VC++ 6.0 because it’s not standard C++, so I’m still working on it in MinGW, I really hope I can fix it. But I still thank you very much!