Only when I include gl.h and glu.h files before glut.h it affects the thing. [...]
Mmmh. Sounds strange...?!
Well, here are my suggestions for today:
1.) What OpenGL libraries are you using? Are you sure that they are compatible with GCC? You could give a try to the OpenGL DevPack (search with google please since the download location I got it from seems to have changed).
2.) Do you mix incompatible headers, maybe? Thus you are using OpenGL headers from one package but linking with others?
3.) Did you give a try to the OpenGL template that ships with C::B? This really should work - it has been tested around thousand times or so... ;-)
4.) Could you please post a full compiler log? To enable full logging go into the compiler setup, choose the tab named "other" and set "Compiler logging" to "Full command line". Then post the full log again - this may help, too.
With regards, Morten.
Ps.: There is a NeHe OpenGL lessons thread somehwere else in the forum. You could try if these (simple) projects compile for you.
Edit: Typos... :-(