GLUT exit redefinition error

Solution 1:

Cause:

The stdlib.h which ships with the recent versions of Visual Studio has a different (and conflicting) definition of the exit() function. It clashes with the definition in glut.h.

Solution:

Override the definition in glut.h with that in stdlib.h. Place the stdlib.h line above the glut.h line in your code.

#include <stdlib.h>
#include <GL/glut.h>

Solution 2:

or this... To fix the error, right click on the project name in the Solution Explorer tab and select Properties -> C/C++ -> Preprocessor -> Preprocessor definitions and append GLUT_BUILDING_LIB to the existing definitions, seperated by semicolons.