University of Wales Trinity Saint David
ACCB5017 - Games Architecture and Mechanics

Environment Setup

Overview

This lab sets up the core C++ toolchain used to build and run graphical projects in Visual Studio: Git for cloning and version control, Visual Studio for the C++ compiler and IDE, and vcpkg for installing and linking third-party libraries such as SFML without hand-editing project settings. By the end you will have compiled and run a program that opens a window, confirming the toolchain works end to end.

Learning Objectives

By the end of this lab you will be able to:

Concept

A C++ project needs three things before a single line of game code will run: a way to fetch and track source (Git), a way to compile and link it (Visual Studio's MSVC toolchain), and a way to pull in third-party libraries like SFML without checking prebuilt binaries into the repository. That third piece is what trips people up. Copying .lib and .dll files by hand works until the next machine, the next SFML version, or the next teammate, and then nothing links.

vcpkg solves this as a package manager for C++. vcpkg install sfml:x64-windows downloads and compiles SFML from source for a specific triplet (the target platform and architecture, here 64-bit Windows) and stores the result in vcpkg's own folder. The important step is vcpkg integrate install, which runs once per machine and registers a single MSBuild properties file that every Visual Studio project on that machine reads automatically. That is why a working SFML project's .vcxproj file has no AdditionalIncludeDirectories or AdditionalDependencies pointing at SFML: the include paths and libraries are supplied globally by vcpkg's integration, not by the project file. Skip integrate install and the exact same project will fail to compile with SFML/Graphics.hpp: No such file or directory.

The pieces you will use directly are: git --version and git clone for source control, the Desktop development with C++ workload inside the Visual Studio Installer, bootstrap-vcpkg.bat to build the vcpkg tool itself, vcpkg integrate install to wire it into MSBuild, and vcpkg install sfml:x64-windows to fetch the library. The finished project uses sf::RenderWindow, sf::VideoMode, window.isOpen(), window.pollEvent(), window.clear() and window.display() to prove the link succeeded.

Packages

PackageDescriptionDocs
Git for Windows Version control client used to clone and manage every project in this module. git-scm.com/download/win
Visual Studio 2022 Community IDE and MSVC C++ compiler/linker/MSBuild toolchain. visualstudio.microsoft.com/vs/community/
vcpkg C++ package manager used to build and link third-party libraries such as SFML. github.com/microsoft/vcpkg
SFML Simple and Fast Multimedia Library, used for windowing and 2D graphics from this lab onward. www.sfml-dev.org/documentation/

Tasks

Task 1 - Install Git

  1. Download Git for Windows from the link in the Packages table above and run the installer, accepting the default options.
  2. Open a terminal (PowerShell or Command Prompt) and confirm the install.

Success condition: git --version prints a version number.

git --version

Task 2 - Install Visual Studio

  1. Download the Visual Studio 2022 Community installer from the link in the Packages table.
  2. In the Visual Studio Installer, tick the Desktop development with C++ workload and start the install.
  3. Once installed, open Visual Studio and create a new project using the Console App (C++) template, name it EnvCheck.
  4. Build and run it with Ctrl+F5.

Success condition: the console window opens and prints Hello World! without any compiler errors.

Task 3 - Install and integrate vcpkg

  1. Open a terminal and clone vcpkg to a short, space-free path such as C:\vcpkg.
  2. Run the bootstrap script to build the vcpkg tool itself.
  3. Run vcpkg integrate install. This registers vcpkg's MSBuild properties file for every Visual Studio project on this machine, which is why you will not see any SFML paths added to your .vcxproj file later.

Success condition: vcpkg integrate install prints Applied user-wide integration for this vcpkg root.

cd C:\
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install

Task 4 - Install SFML and open a window

  1. From the C:\vcpkg folder, install SFML for the 64-bit Windows triplet. This compiles SFML from source and can take several minutes.
  2. In Visual Studio, create a new Console App (C++) project called SFMLCheck.
  3. Set the solution platform to x64 in the toolbar dropdown. vcpkg installed the x64-windows triplet, so an x86 build will fail to link.
  4. Replace the contents of the generated .cpp file with the code below and run it with Ctrl+F5.

If the build fails with SFML/Graphics.hpp: No such file or directory, re-check that vcpkg integrate install completed in Task 3. If it fails at the link step with unresolved externals, re-check the platform is set to x64.

Success condition: a window titled SFML works opens, filled with a solid blue colour, and closes cleanly when you click its close button.

vcpkg install sfml:x64-windows
SFMLCheck.cpp
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works");

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear(sf::Color(100, 149, 237));
        window.display();
    }

    return 0;
}