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.
-
By the way, I would stop calling it Mac OSX 9 if I were you. I see that and immediately think "Mac OS Classic", because my mind drops the "X". The official name for the platform/release is actually Mac OS X 10.9 – Andon M. Coleman May 03 '14 at 22:31
-
Hi Adam. Ok, thanks. If I said OSX 9, then that was my mistake! I assumed everybody would know that's Maverics. – user3600260 May 03 '14 at 22:35
-
Yeah, it is just a little on the confusing side because prior to OS X, Apple had plain old "Mac OS". There was a Mac OS 9, the last version of Mac OS before they moved to OS X. When OS X was first released machines would ship with it and a copy of Mac OS 9 (for compatibility with older software). That was affectionately known as "Mac OS Classic". So for veteran OS X users, calling it Mac OSX 9 can get pretty confusing ;) – Andon M. Coleman May 03 '14 at 22:39
3 Answers
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

- 421
- 3
- 4
-
Doesn't work with my brew! Error: No available formula for glfw3 Searching formulae... Searching taps... homebrew/versions/glfw3 – Pranjal Mittal May 28 '15 at 23:02
-
5As of now, `brew install glfw` will install glfw-3.2.1. And the minimalist usage of it can be `g++ main.cpp -lglfw`. – Hustlion Apr 02 '17 at 03:58
-
1@Pranjal @Hustlion seems to no longer be true -- no such formula as `glfw` or `glfw3` – Chris Burt-Brown May 03 '17 at 22:50
-
I'm able to install the package from brew. Just needed to use "glfw" for the compiler lib link instead, instead of "glfw3". – Connor Clark Sep 04 '18 at 01:42
-
In **2023**, this continues to (basically) work, on Apple Silicon, on macOS (I'm at 12.6). As @ConnorClark says glfw3→glfw. I will note that the `brew install` put nothing in `/usr/local/lib` or `/usr/local/include`. Perhaps that is a new Homebrew convention? You may need to adjust search paths. – Craig Reynolds Feb 07 '23 at 01:13
To build the GLFW library from source, only a few steps are required:
Download and extract the GLFW source code.
Open the Terminal.
cd
to the extracted directory.Type in
cmake .
, hit return.A
Makefile
will be created for you.Type in
make
, hit return.After the compilation process, type in
sudo make install
.
The libraries will be copied to /usr/local/lib/
, the header files to /usr/local/include/
.
Note: You'll need a compiler suite installed to build software, this would usually be the XCode Command Line Tools package. For this, install and launch XCode from the Store or download the tools from the developer site.

- 7,088
- 6
- 47
- 96
-
Hi Adam. Thanks a lot. I will try this now. I'm great programming non-realtime graphics but not so good yet with OpenGL. – user3600260 May 03 '14 at 22:18
-
Hi Adam, Thanks a lot. You're a god send. This worked like a charm. I did have to enable root user in Maverics before I could "su root" and make install to the /user/local/libs and include directories. Otherwise, I didn't have permission to install to this directory. Tim – user3600260 May 03 '14 at 23:42
-
1No problem! Great that it works. Just a note, instead of `su root` you can always use `sudo
` to run a command with root permission, e.g. `sudo make install`. (Don't forget to mark this answer as accepted ;-)) – Appleshell May 04 '14 at 00:20
If you have troubles with linker try to compile like this:
g++ youSource.cpp -I/usr/local/include -L/usr/local/lib -lglfw3 -framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo
or just:
g++ youSource.cpp -I/usr/local/include `pkg-config --cflags glfw3` `pkg-config --static --libs glfw3`

- 1,074
- 1
- 14
- 33
-
The first command worked for me. Do you mind explaining the later part of it? (-framework Cocoa -framework OpenGL -framework IOKit -framework CoreFoundation -framework CoreVideo) – Gregory-Turtle Nov 12 '16 at 22:32