Glut.h and cstdlib

Hi,

I have a short program that will produce random numbers using just an #include <iostream> or #include <cstdlib>.

If I also use #include <GL/glut.h> I get an error that there is a redefinition of exit.

I can either get random numbers OR be able to use exit(0) with a mouse click but I can’t seem to get both.

I am using MicroSoft C++ 2005 with OpenGL.

Try to include <cmath>

rand() is not included in cmath

fyi, rand() is in <cstdlib>, and you need to include glut after any header that declares or includes exit (e.g. stdlib). There’s a commented section in glut.h that explains the details if you’re interested…

Eureka!

Yes, now I am getting random numbers (or better yet randomly colored dots) and can still exit from the menu.
Thanks!

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.