Skip to content

Setup C++ development environment on Windows

These steps were tested on Windows 11, 23H2. Scripts are PowerShell.

Visual Studio 2022

This is needed for the C++ compiler. Install Visual Studio 2022 Community Edition.

During installation select C++ desktop development and latest Windows 10 and Windows 11 SDKs.

After installation open Visual Studio and check for updates. Install the latest 2022 version that is available.

CMake

Install via Windows Package Manager:

winget install kitware.cmake

ninja

Install via Windows Package Manager:

winget install Ninja-build.Ninja

PowerShell Configuration

This will allow you to execute PowerShell scripts locally on your machine. In PowerShell as Administrator:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

Environment

Update $env:PSModulePath so that you can use PowerShell modules. In PowerShell as Administrator:

[Environment]::SetEnvironmentVariable("PSModulePath", "$HOME/Documents/WindowsPowerShell/Modules;" + $env:PSModulePath, "Machine")

VSSetup Module

In PowerShell as Administrator:

Install-Module VSSetup -Scope CurrentUser
Close and reopen PowerShell. Now you can use the VSSetup commands.

List the Visual Studio installations:

Get-VSSetupInstance

This finds the installation path for Visual Studio 2022:

Get-VSSetupInstance `
| Select-VSSetupInstance -Version '[17.0,]' `
| Select-Object -ExpandProperty InstallationPath

See Selecting an Instance