Chapter 2. Installing SGL

Table of Contents

2.1. Installing on Microsoft Windows 10 with Visual Studio 2017
2.2. Installing on Apple Mac macOS
2.3. Installing on Linux

The SGL library is relatively simple to install on all the major platforms: Microsoft Windows, Apple macOS, and Linux.

2.1. Installing on Microsoft Windows 10 with Visual Studio 2017

C++ development under Visual Studio 2017 includes the OpenGL library, but it lacks GLUT. The GLUT library is available from http://www.xmission.com/~nate/glut.html. The zip file downloadable from this site contains the Windows binaries. The SGL library is available from https://github.com/halterman/SGL. After downloading and unpacking the GLUT files and downloading the SGL headers, you must place them in a location accessible to your C++ projects. One place to put them is in C:\SGL. The following procedure creates one possible organization for the SGL files:

  1. Create C:\SGL\include\GL

  2. Copy glut.h, sgl.h, and sgl.hpp into C:\SGL\include\GL.

  3. Create C:\SGL\include\lib

  4. Copy glut32.lib into C:\SGL\include\lib.

  5. Copy glut32.dll into C:\Windows (you need administrator privileges for this step). Rather then adding glut32.dll to the C:\Windows directory, you also may copy the glut32.dll file to the same location as your .cpp source code in each and every Visual Studio project in which you use the SGL. When executing the program under Visual Studio, the environment automatically will load the DLL. If you instead place the DLL in the C:\Windows folder, this copying is unnecessary.

When creating a new project in Visual Studio 2017, adjust the project properties as follows:

  1. In the VC++ Directories section:

    • Add c:\SGL\include to the Include Directories section, and

    • Add c:\SGL\lib to the Library Directories section, and

  2. In the Linker section, under Input add glut32.lib.

It is possible to compile SGL applications from the command line using Visual C++. To do so, use the Developer Command Prompt for Visual Studio (open the Start menu and type dev to find it). To simplify the build process, create the following batch file named sglcc.bat:

cl /W4 /EHsc /nologo /std:c++17 %* /IC:\SGL\include \
/link /LIBPATH:c:\SGL\lib glut32.lib
copy c:\SGL\bin\glut32.dll .

To build an SGL application named myapp.cpp, type

sglcc myapp.cpp


Copyright  ©2019 Richard L. HaltermanVersion 0.9.5February 17, 2019
Creative Commons License This work is licensed under a Creative Commons License.