FreeGLUT在Mac OS X Lion上

时间:2021-04-13 16:45:30

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.

一些上下文:我正在学习使用OpenGL的教程。本教程需要两个库才能工作。其中一个图书馆是FreeGLUT。我正在用Lion操作OS X。

I've downloaded FreeGLUT and followed the instructions for 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.

编辑:好的,我发现不是编译器,而是因为某些原因,这些文件不存在。试着弄清楚他们为什么不在那里。

3 个解决方案

#1


12  

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.

这应该能解决你的问题。

#2


0  

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。手动复制粘贴lib并包含freeglut的文件夹(通过macports)并修改#include_GL/freeglut。h >内部框架。cpp(框架文件夹),以便找到标题。也要在文件夹名称中填充空格,例如tut13 Impostors -> Tut_13_Impostors

it works for me

它适合我

more details here

更多细节在这里

#3


0  

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 3.2(狮)你会得到一个核心内容是足够相似,至3.3,但不幸的是这是不符合过剩- OS X包括原始过剩(由于许可修改的问题),这需要很多过时的OpenGL函数不能在3.2核心上下文。

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开始)。

https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.11.dmg

https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.11.dmg

#1


12  

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.

这应该能解决你的问题。

#2


0  

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。手动复制粘贴lib并包含freeglut的文件夹(通过macports)并修改#include_GL/freeglut。h >内部框架。cpp(框架文件夹),以便找到标题。也要在文件夹名称中填充空格,例如tut13 Impostors -> Tut_13_Impostors

it works for me

它适合我

more details here

更多细节在这里

#3


0  

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 3.2(狮)你会得到一个核心内容是足够相似,至3.3,但不幸的是这是不符合过剩- OS X包括原始过剩(由于许可修改的问题),这需要很多过时的OpenGL函数不能在3.2核心上下文。

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开始)。

https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.11.dmg

https://dl.bintray.com/xquartz/downloads/XQuartz-2.7.11.dmg