开发者

Where are the OpenGL header files located on MacOSX?

In /usr/include ,

I tried grepping for GL gl and OpenGL .. .but can't find it.

Where are these header files located?开发者_运维百科


They are located at /System/Library/Frameworks/OpenGL.framework/Headers. To include them, just use:

   #include <OpenGL/gl.h>
   #include <OpenGL/glu.h>
   #include <OpenGL/glext.h>
   #include <GLUT/glut.h>

etc. Make sure to link against the appropriate frameworks, eg)

cc <your_file.c> -framework GLUT -framework OpenGL 

for OpenGL and GLUT


This is a good old thread to revive, because the correct answer changed. The accepted answer of /System/Library/Frameworks/OpenGL.framework/Headers was totally correct when it was written. But with Xcode 5 (I believe it changed with Xcode 4 already), this is not the case anymore.

All SDK files are now installed into /Applications/Xcode.app. The exact location of the headers depends on the platform the application is built against. As an example, the OpenGL headers for OS X 10.9 are in:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Headers


It's worth noting that one also needs to have XCode itself set up (not just installed), as well as the XCode Command-Line Tools, even if one is not building the application in XCode.


XCode automatically exposes all header files from a framework added to a project via the framework's name. So, "cocoa.h" is part of "cocoa.framework" - hence #include <cocoa/cocoa.h>

OpenGl is included <OpenGL/gl.h> rather than the more expected <GL/gl.h> on other platforms.


In MacOS 10.12.6, they're under /opt/X11/include, e.g. /opt/X11/include/GL/gl.h.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜