Q: How to use openGL with gcc on Mac? I'm trying to run this openGL example on my Mac from command line using gcc. The XCode is installed, gcc was used many time with other programs (w\o graphics).
Following to this topic I run:
g++ 1.cpp -framework OpenGL -lGLU -lglut

and get:
1.cpp:12:21: fatal error: GL/glut.h: No such file or directory

I found glut.h at /System/Library/Frameworks/GLUT.framework/Headers/ and noted that structure is different (not GL folder). But even removing GL/ and using -I/System/Library/Frameworks/GLUT.framework/Headers/ does not help a lot..
So I wonder - how to use openGL with gcc on Mac properly?

A: On mavericks using the include
#include <GLUT/glut.h>

works if you compile with the following line 
g++ 1.cpp -framework OpenGL -framework GLUT


A: Your first problem is that Apple's Framework infrastructure actively sabotages portability of code by placing OpenGL headers in a nonstandard path. On Apple platforms the OpenGL headers are located in a directory named OpenGL instead of just GL.
So to portably include the headers you have to write
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif

Your other problem is, that GLUT is not part of OpenGL and an independent, third party library, that's no longer contained within the OpenGL framework. You need to use the GLUT Framework. And of course that one uses nonstandard include paths as well:
#ifdef __APPLE__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif

Compile with the -framework OpenGL -framework GLUT options.
