xcode mac 上缺少 OpenGL 头文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18647976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Missing OpenGL headers on mac
提问by Andrés
I am trying to use OpenGL in mac, but when I am including the glut header, It includes the OpenGL one an then It's not able to find the OpenGL/gl.h
header.
I have looked the problem up in the internet, and It seems that this files should be inside the /System/Library/Frameworks/OpenGL.framework/Headers
directory, but such subdirectory does not exist. I have tried reinstalling XCode and didn't work.
我正在尝试在 mac 中使用 OpenGL,但是当我包含 glut 标头时,它包含 OpenGL 一个,然后它无法找到OpenGL/gl.h
标头。我在网上查过这个问题,好像这个文件应该在/System/Library/Frameworks/OpenGL.framework/Headers
目录里面,但是这样的子目录不存在。我试过重新安装 XCode 并没有奏效。
Any suggestions of how should I proceed.
关于我应该如何进行的任何建议。
Some specifics:
here is what /System/Library/Frameworks/OpenGL.framework/Versions/Current
looks like:
一些细节:
这里是/System/Library/Frameworks/OpenGL.framework/Versions/Current
这样的:
localhost@Current$ ls -la
total 368
drwxr-xr-x 7 root wheel 238 Oct 7 2012 .
drwxr-xr-x 4 root wheel 136 Oct 7 2012 ..
drwxr-xr-x 16 root wheel 544 Oct 7 2012 Libraries
-rwxr-xr-x 1 root wheel 185184 Oct 3 2012 OpenGL
drwxr-xr-x 3 root wheel 102 Jun 16 2011 PlugIns
drwxr-xr-x 14 root wheel 476 Oct 7 2012 Resources
drwxr-xr-x 3 root wheel 102 Oct 7 2012 _CodeSignature
Thank you all
谢谢你们
采纳答案by Andrés
For everyone else who is having this problem, the solution is fairly easy. The problem is that probably not all the command line tools are installed, so the key is to install them. You just need to follow what is suggested in thispost and install all the command line tools that are missing. Then you'll have a beautiful OpenGL hello world running smoothly :D :D
对于遇到此问题的其他所有人,解决方案相当简单。问题是可能没有安装所有的命令行工具,所以关键是安装它们。你只需要遵循什么建议在这个职位和安装都丢失了所有的命令行工具。然后你就会有一个漂亮的 OpenGL hello world 顺利运行:D :D
回答by Richard Kettering
In mavericks (10.9), these got moved. The stuff in /System/Library/Frameworks no longer has any development headers; it seems to be purely a deployment build of the frameworks. So, Andés is right - he's looking exactly where he was told to look, but the files he's looking for simply aren't there.
在小牛队(10.9)中,这些被感动了。/System/Library/Frameworks 中的东西不再有任何开发头文件;它似乎纯粹是框架的部署构建。所以,Andés 是对的——他正在寻找他被告知要查看的确切位置,但他正在寻找的文件根本不存在。
Instead, XCode itself stores these as part of its install - XCode comes with multiple SDKs for various versions of OS X, and inside these, there are the headers for these libraries. For example:
相反,XCode 本身将这些作为其安装的一部分进行存储——XCode 为各种版本的 OS X 提供了多个 SDK,在这些 SDK 中,有这些库的头文件。例如:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/
回答by Andon M. Coleman
On all of my OS X development machines, I have: /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
在我所有的 OS X 开发机器上,我有: /System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
I even have SDKs for targeted versions:
我什至有针对目标版本的 SDK:
/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h
...
/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers/gl.h /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/OpenGL.framework /Versions/A/Headers/gl.h
...
[ andon@Aleph : ~ ] ls -lA "/System/Library/Frameworks/OpenGL.framework/Versions/Current/Headers"
total 1464
-rw-r--r-- 1 root wheel 557B Mar 3 2010 CGLContext.h
-rw-r--r-- 1 root wheel 381B Mar 3 2010 CGLCurrent.h
-rw-r--r-- 1 root wheel 389B Mar 3 2010 CGLDevice.h
-rw-r--r-- 1 root wheel 14K Mar 3 2010 CGLIOSurface.h
-rw-r--r-- 1 root wheel 128K Mar 3 2010 CGLMacro.h
-rw-r--r-- 1 root wheel 6.4K Feb 12 2011 CGLProfiler.h
-rw-r--r-- 1 root wheel 28K Feb 12 2011 CGLProfilerFunctionEnum.h
-rw-r--r-- 1 root wheel 1.5K Mar 3 2010 CGLRenderers.h
-rw-r--r-- 1 root wheel 14K Mar 3 2010 CGLTypes.h
-rw-r--r-- 1 root wheel 5.6K Mar 3 2010 OpenGL.h
-rw-r--r-- 1 root wheel 151K Mar 3 2010 gl.h
-rw-r--r-- 1 root wheel 267K Mar 3 2010 glext.h
-rw-r--r-- 1 root wheel 328B Mar 3 2010 gliContext.h
-rw-r--r-- 1 root wheel 63K Mar 3 2010 gliDispatch.h
-rw-r--r-- 1 root wheel 16K Mar 3 2010 glu.h
-rw-r--r-- 1 root wheel 2.6K Mar 3 2010 gluContext.h
-rw-r--r-- 1 root wheel 2.2K Mar 3 2010 gluMacro.h
Regardless where the file is, the fact that it's in .../Library/Frameworks/OpenGL.framework/...
is an indication that you need to add -framework OpenGL
to your compiler/linker switches for includes and libraries to be located correctly.
不管文件在哪里,它所在的事实.../Library/Frameworks/OpenGL.framework/...
表明您需要添加-framework OpenGL
到编译器/链接器开关,以便正确定位包含和库。