Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to build and use GLFW

📅 2015-Aug-25 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cmake, glfw, glut, ldconfig ⬩ 📚 Archive

GLFW is a library for OpenGL created by Camilla Berglund. It is a modern replacement to GLUT, to draw windows and handle input.

GLFW 2.x

Ubuntu ships with an ancient version of GLFW that can be installed easily:

$ sudo apt install libglfw-dev

However, it is highly recommended to use GLFW 3.x. It has a different API and your source code and build options will need to be changed to use it.

To remove this ancient GLFW:

$ sudo apt remove libglfw-dev glfw2

GLFW 3.x

I like to install GLFW from Github. You could also get one of its stable releases, the installation steps would be the same for either.

$ git clone
$ cd glfw
$ mkdir build
$ cd build
$ sudo make install

Note that I highly recommend using checkinstall as described here instead of doing this.

$ sudo ldconfig

If you do not do this, you get an error similar to that described here.

#include <GLFW/glfw3.h>

Tried with: GLFW 20150825 and Ubuntu 14.04

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧