macos Mac OS X Lion 上的 FreeGLUT
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10866331/
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
FreeGLUT on Mac OS X Lion
提问by jasonaburton
Some context: I am going through a tutorialon 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.
一些上下文:我正在阅读有关使用 OpenGL的教程。本教程需要几个库才能工作。这些库之一是 FreeGLUT。我在 OS X 上使用 Lion。
I've downloaded FreeGLUT and followed the instructionsfor installation, but when I run the 'make all' command I get this error:
我已经下载了 FreeGLUT 并按照安装说明进行了操作,但是当我运行“make all”命令时出现此错误:
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.
编辑:好的,我发现它不是编译器,而是由于某种原因这些文件不存在。想弄清楚为什么他们不在那里。
回答by Hassan
On Mac, the location of those header files are not the same as on Linux. So in the code, replace this:
在 Mac 上,这些头文件的位置与在 Linux 上不同。所以在代码中,替换这个:
#include <GL/gl.h>
#include <GL/glu.h>
with this:
有了这个:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
and that should fix your issue.
这应该可以解决您的问题。
回答by RD1
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.
该教程 OpenGLBook.com 基于 OpenGL 4.0 核心上下文,并以 3.3 核心上下文作为替代。充其量在 OS X(使用 Mountain Lion)上,您将获得与 3.3 足够相似的 3.2 核心上下文 - 但不幸的是,这与 GLUT 不兼容 - OS X 包括原始 GLUT(由于许可问题未修改),这需要很多在 3.2 核心上下文中不可用的过时 OpenGL 函数。
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).
如果您想在 OS X(10.6.3 或更高版本)上完成本教程而不必处理许多烦人的不兼容问题,并且使用面向未来的 OpenGL,我建议您安装最新版本的 XQuartz(2.7.2 或更高版本),它包括 FreeGLUT(从 2.8.0 开始)。
回答by Nikolaos Giotis
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
通过macports安装freeglut,修改premake4.lua,使其在glsdk中除了freeglut之外构建非官方的OpenGL SDK。手动复制并粘贴 freeglut 的 lib 和 include 文件夹(通过 macports),并在 framework.cpp(框架文件夹)中修改 #include_GL/freeglut.h> 以找到标题。还要填写文件夹名称中的空白,例如 Tut 13 Impostors -> Tut_13_Impostors
it works for me
这个对我有用
more details here
更多细节在这里