FreeGLUT on Mac OS X Lion
Asked Answered
O

3

12

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.

Ouphe answered 2/6, 2012 at 22:12 Comment(2)
I'm not familiar with Mac, but you need to install both the OpenGL and GLU development libraries to build FreeGLUT, which depends on them.Seaman
Using Xcode you can just add a library to a project and OpenGL is a library that can be added so I just assumed those files were installed. Any ideas on how I go about doing that? Hehe...Ouphe
J
16

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.

Jaws answered 2/6, 2012 at 22:28 Comment(10)
Do you know where in the FreeGLUT files I will need to make that change?Ouphe
No, I don't, but as far as I know, you don't need it. GLUT is pre-installed on OS X, so you can just follow the tutorial with the GLUT you already have on your machine, and the code should be exactly the same.Jaws
The impression I got was that FreeGLUT was very different than GLUT and the example would not work as written. If I can't get this working, I will try using GLUT.Ouphe
So I found where I needed to make that change, but now I am getting a new error: "GL/glx.h: No such file or directory" (same thing) except this time when I changed it to OpenGL/glx.h the error still appeared...Ouphe
That is strange. I'm not very familiar with FreeGLUT, so I haven't had to mess with that before. I'm guessing the installation of GLUT on your machine is not compatible with the FreeGLUT you downloaded. Honestly, I'd just use regular old GLUT if I were you.Jaws
Well, then my next question is, what is the difference? Why am I being recommended to use FreeGLUT? (I'm just as unfamiliar as you, most likely more unfamiliar).Ouphe
It's my understanding that they do exactly the same thing. I just looked up the Wikipedia article, and it looks like FreeGLUT is just an alternative to GLUT.Jaws
Okay. GLUT it is then. Thanks for your help!Ouphe
@jasonaburton: FreeGLUT is not the same thing as GLUT. FreeGLUT implements many of the same functions, but it also adds many more that were never in GLUT. I don't know what OSX ships with, but it's probably a hacked version of the original GLUT, which likely won't support any of the FreeGLUT extensions.Bohol
cross-platform solution: #ifndef __APPLE__ #include <GL/gl.h> #else #include <OpenGL/gl.h> #endifCoriolanus
S
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.

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

Shagbark answered 24/8, 2012 at 5:2 Comment(1)
Hi, I was not able to get a 3.2 context using FreeGlut (via XQuartz). I was able to get a 2.1 context with out any issues, but I could only get 3.2 via Cocoa. I'd love to find out if this can be done.Kiesha
F
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

it works for me

more details here

Foyer answered 1/9, 2012 at 13:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.