问题
Some context: I am going through a tutorial on using OpenGL. The tutorial requires a couple libraries in order to work. One of those libraries is FreeGLUT. I am on OS X using Lion.
I've downloaded FreeGLUT and followed the instructions for installation, but when I run the 'make all' command I get this error:
error: GL/gl.h: No such file or directory
error: GL/glu.h: No such file or directory
I've scoured the internet for a solution and all I've been able to understand from this is that the compiler is having trouble locating these files and that the path that the compiler is using needs to be changed.
EDIT: Okay, I've figured out that it's not the compiler, it is that for some reason those files are not there. Going to try figure out why they are not there.
回答1:
On Mac, the location of those header files are not the same as on Linux. So in the code, replace this:
#include <GL/gl.h>
#include <GL/glu.h>
with this:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
and that should fix your issue.
回答2:
install freeglut via macports, modify premake4.lua so that it builds the Unofficial OpenGL SDK in the glsdk apart from freeglut. manually copy and paste the lib and include folders of the freeglut (via macports) and modify #include_GL/freeglut.h> inside framework.cpp (framework folder) so that it finds the header. also fill the blanks in folder names, e.g. Tut 13 Impostors -> Tut_13_Impostors
it works for me
more details here
回答3:
That tutorial, OpenGLBook.com, is based around OpenGL 4.0 core contexts, with 3.3 core contexts as an alternative. At best on OS X (with Mountain Lion) you'll get a 3.2 core context which is similar enough to 3.3 - but unfortunately this is incompatible with GLUT - OS X includes the original GLUT (unmodified due to licencing issues), which requires many obsolete OpenGL functions that aren't available in 3.2 core contexts.
If you want to do this tutorial on OS X (10.6.3 or later) without having to deal with many annoying incompatibilities, and with future-proof OpenGL, I recommend installing a recent version of XQuartz (2.7.2 or later), which includes FreeGLUT (2.8.0 to start with).
https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.11.dmg
来源:https://stackoverflow.com/questions/10866331/freeglut-on-mac-os-x-lion