OpenGL 3.3/4.1 on Mac OSX 10.9 using GLFW library

user3600260 picture user3600260 · May 4, 2014 · Viewed 33.1k times · Source

I’m trying to use OpenGL 3.3/4.1 on my Mac OSX 10.9 now that its finally available. I’ve been using the SuperBible 5 book and its examples to learn 3.3. I just found out that its actually only running OpenGL 2.1 though for my examples when my vertex shader started refusing to compile. I found that I need to get ahold of this GLFW library to do OpenGL windowing for me. This library will allow me to use the 4.1 version of OpenGL that OSX is capable of running. My question is does anybody have a static version of the Mac OSX 9 OpenGL library GLFW version 3.0.4 they can just send me? It is kind of a real pain trying to build the library from scratch as because it involves installing CMake and then the library code and then trying to get it all to work together and compile. I really only need the library so I can start getting OpenGL 3.3/4.1 to run.

Answer

juanandresnyc picture juanandresnyc · May 8, 2014

I will suggest installing glfw via homebrew http://brew.sh/ The advantage being you can always uninstall it neatly by doing brew uninstall glfw3!

You need to have the "Command Line Tools for Xcode" and Xcode install https://github.com/Homebrew/homebrew/wiki/Installation

xcode-select --install

Once Homebrew is installed, open the terminal and run

brew update

brew tap homebrew/versions

brew install glfw3 for glfw3 OR

brew install glfw2 for glfw2

Also, if you desire an static build, use the flag --static

brew install --static glfw3

The libraries and include files will be available at usr/local/lib and usr/local/include

Now, if you have a program that relies in opengl and glfw, you'd want to compile it something like this: gcc program.c -o myapp -framework OpenGl -lglfw3 (or -lglfw2)

If you still have some problems with the glfw header file, you can do:

gcc program.c -o myapp -framework OpenGl -I/usr/local/include -lglfw3