GLFW is a library for OpenGL created by Camilla Berglund. It is a modern replacement to GLUT, to draw windows and handle input.
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
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.
- Get the source:
$ git clone https://github.com/glfw/glfw.git
- Build the library. Note that we request CMake to create shared library files. Why this is not the default on Linux puzzles me!
$ cd glfw $ mkdir build $ cd build $ cmake -D BUILD_SHARED_LIBS=ON ..
- Install the library:
$ sudo make install
Note that I highly recommend using checkinstall as described here instead of doing this.
- Update the dynamic linker cache, so that the
libglfw.soshared library file can be loaded at runtime:
$ sudo ldconfig
If you do not do this, you get an error similar to that described here.
- To use GLFW 3.x calls in your code, include the header file:
- To link and build your code use the library directive:
-lglfwto your build options or CMake.
Tried with: GLFW 20150825 and Ubuntu 14.04