Prepare your computer for SGG development (C++)

Summary

This is a tutorial on how to setup Simple Game Library to develop an enhanced SDL application. Since we are using Windows in this tutorial, most steps are straightforward. The only handicap is that the scripts of compilation at the github repository are not well written and error messages are misleading.

The main problem you might encounter is that the path of the Visual Studio is hard-coded in some scripts (for example build_sgg_x64.bat) which means that if you are not using the default installation locations for visual studio the setup may fail. The error messages are not very helpful (they only report that the visual studio is not installed) so a newbie can easily be confused.

Lets get started.

Installation

Install VS Community edition

You need to install a compatible version of VS with SGG. In order to find the latest supported version of Visual Studio Community for the SGG you can either check for the comments of last commit for the installation scripts (e.g. look up for the comments of build_sgg_x64.bat) at the github repository or you can check the script source code.

The installation is pretty straightforward for Visual Studio so no further instructions are included in this article.

Install Simple Game Graphics library

Download SGG

Download the library from the official github link and extract to any directory of your choice. Alternatively, you can clone the repository from command line:

git clone https://github.com/cgaueb/sgg  

Compile SGG

If you have installed VS at the default locations you can simply run the script for your architecture (e.g. build_sgg_x64.bat for windows). There are some things that can go wrong. Check troubleshooting section for some of those cases.

If you are not using the default locations, you need to edit the file manually. The fastest way is to remove all the IF EXISTS statements of the scripts and replace with your custom paths.

For example:

set STUDIO_VERSION=2022
set STUDIO_EDITION=Community
set STUDIO_PATH=e:\_ProgramFilesSlow\vs2022

echo Compiling with Visual Studio %STUDIO_VERSION% %STUDIO_EDITION%
...

Repeat for the demo build script and run them both.

Once the library has been compiled you will have the following files at the lib directory:

  • sgg.lib
  • sggd.lib
  • sggd.pdb

These are the files you need to link to when creating the new project.

Setup a new project

Create empty project

Create a new empty project and select place solution and project in the same directory.

Copy required files from demo

Copy the following files as shown in the table:

Demo directoryYour project directory
./3rdparty./3rdparty
./lib./lib
sgg/graphics.h./3rdparty/include/sgg/graphics.h
sgg/scancodes.h./3rdparty/include/sgg/scancodes.h
demo/demo.cpp./demo.cpp
demo/vecmath.h./vecmath.h
./bin/assets./bin/assets
./bin/*.dll./bin/*.dll
./bin/sggd.lib.pdb./bin/sggd.lib.pdb

Configure project

You need to make the following configuration adjustments: (configuration: Debug/x64)

ConfigurationValue
General → Output directory:      $(SolutionDir)\bin\
Debugging → Working directory:$(SolutionDir)\bin\
C/C++ → Additional include directories$(SolutionDir)/3rdparty/include
Linker → Additional library directories:  $(SolutionDir)/3rdparty/lib
Linker → Additional dependencies… ;sggd.lib

Screenshots

Project configuration
Debugging configuration
Compiler configuration
Linker configuration

Additional useful tools

Here is a list of other useful tools to use with SGG:

Troubleshooting

cl not found

In order for the build scripts to run, the environment variables need to be setup correctly for x64 compilation. The default command prompt does not do that.

You need to open “x64 native tools command prompt” from the windows menu and run the build scripts from it.

For more read here.

msvcp140d.dll is not found

If you get a similar message then you need to install older versions of the build tools than the version of the Visual studio you have installed.

Run the Visual Studio Installer and be careful on the choices you are given. Normally it will ask you to select which modules you will install. From that menu select the proper version of the build tools and install it.

It’s recommended to reboot afterwards.