To download and install the essential libraries onto your Mac system, we'll have to install a package manager for Mac known as Homebrew. Homebrew will help us in installing all the necessary packages and libraries to run our OpenGL code.
To install Homebrew, go to https://brew.sh/, copy the path highlighted in the following screenshot, paste it into your Terminal, and then hit Enter. The prompt will download and install Homebrew on your system:
Path on Homebrew homepage
Once we've installed Homebrew, we'll download the GLFW and GLEW libraries onto our system. Let's install GLFW first. To do that, we need to type the following command in the Terminal window:
brew install glfw3
In the preceding command, you must have observed we've included the number 3; the reason for that is that if you just type glfw, it installs an older version, which we don't want, so inserting glfw3 will install the latest version. Hit Enter and the libraries will be downloaded onto your system.
Now, we're going to do the same process for GLEW; type the following command in the Terminal:
brew install glew
We don't need to put any version for this; just press Enter and the necessary files will be downloaded. That's it for the libraries to download onto our system.
Make a note that, since we're installing the libraries on the system itself and not in our project, whenever you move your project to a different system, you will have to install these libraries onto that particular system.
Once we've downloaded and installed all the essential libraries with the help of Homebrew, we'll now move on to setting up Xcode for OpenGL.
Make sure Xcode is installed on to your system. If not, please follow these instructions and install it on your system.