Skip to content

GLFW for ArrayFire

pradeep edited this page Jul 15, 2021 · 26 revisions

Introduction

This document explains how to build and/or install GLFW on various operating systems and distributions.

ArrayFire requires GLFW (>=3.1.2) for graphics support. GLFW v3.0.4 will also work, but is not recommended as bug fixes following that release may create problems. Whatever you do, do not install GLFW 2!

Windows

It is highly recommended to simply download the GLFW 64-bit binaries for Windows from the GLFW website.

OSX

Install GLFW using Homebrew like so:

brew tap homebrew/versions
brew install glfw

Linux

Most new Linux distributions have GLFW in their respective package manager. Common package names are:

  • libglfw3-dev (Ubuntu and Debian distributions)
  • glfw-devel (Fedora)
  • glfw (Arch)

Some of the older Linux distributions do not ship with GLFW 3.x. The solution to this is to use 3rd party package manager repositories to install GLFW or build it as shown below. You can search the internet for repositories with GLFW 3 that support your distribution.

Building GLFW (Linux and OSX)

GLFW on Linux depends on X.Org Server and GLU (OpenGL Utility Library) packages. To build GFLW, you will also need gcc and cmake.

For Debian based systems:

sudo apt-get install build-essential cmake cmake-curses-gui xorg-dev \
     libglu1-mesa-dev libxinerama-dev libxcursor-dev

For Redhat / CentOS systems:

sudo yum install gcc gcc-c++ cmake xorg-x11-server-devel \
     xorg-x11-server-utils libXrandr-devel \
     libXi-devel libXinerama-devel libXcursor-devel

Once the dependencies are installed, glfw3 can be built and installed using the following commands:

wget https://github.com/glfw/glfw/archive/refs/tags/3.3.4.zip -O glfw-3.3.4.zip
unzip glfw-3.3.4.zip
cd glfw-3.3.4
mkdir build
cd build
cmake .. -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
make -j8
sudo make install

After installation, make sure you add the following to the end of your bash config file.

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH