Skip to content

Instantly share code, notes, and snippets.

@winterknife
Last active August 18, 2025 23:06
Show Gist options
  • Save winterknife/0b177a75a55bad895b19aad64cffa14f to your computer and use it in GitHub Desktop.
Save winterknife/0b177a75a55bad895b19aad64cffa14f to your computer and use it in GitHub Desktop.
Tutorial to set up a Windows x86 development environment using the GCC + Clang/LLVM toolchain

OPTION 1: Windows Subsystem for Linux (WSL)

  1. Open a Command Prompt as Administrator
  2. Enable WSL
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
  1. Enable Virtual Machine Platform
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  1. Reboot machine
shutdown.exe /r /t 0
  1. Open a Command Prompt as Administrator
  2. Set WSL 2 as the default version
wsl.exe --set-default-version 2
  1. Install WSL with Ubuntu 24.04.2 LTS as the Linux distribution
wsl.exe --install --distribution Ubuntu-24.04
  1. Create a user account and password for the newly installed Linux distribution
  2. List installed Linux distributions
wsl.exe --list --verbose
  1. Launch Ubuntu-24.04 application
  2. Update and upgrade packages
sudo apt update && sudo apt upgrade
  1. Install Mingw-w64
sudo apt install mingw-w64
  1. Install GNU Make
sudo apt install make
  1. Install Java
sudo apt install openjdk-21-jdk
  1. Install Clang
sudo apt install clang
  1. Install Netwide Assembler (NASM)
sudo apt install nasm
  1. Invoke build tools
x86_64-w64-mingw32-gcc --version && clang --version

OPTION 2: MSYS2

  1. Launch Windows PowerShell application
  2. Download the archive
(New-Object System.Net.WebClient).DownloadFile('https://github.com/msys2/msys2-installer/releases/download/2025-06-22/msys2-base-x86_64-20250622.sfx.exe', 'msys2.exe')
  1. Compute checksum of the archive
Get-FileHash ./msys2.exe -Algorithm SHA256 | Format-List
  1. Extract the archive to C:\msys64
.\msys2.exe -y -oC:\
  1. Delete the archive
Remove-Item msys2.exe
  1. Add exclusion(s) for Mandatory ASLR (Run as Administrator)
Get-ChildItem -Recurse -File -Path 'C:\msys64\*.exe' | ForEach-Object -Process { Set-ProcessMitigation -Name $_.Name -Disable ForceRelocateImages }
  1. Initialize MSYS2
C:\msys64\usr\bin\bash -lc ' '
  1. Update MSYS2 (core)
C:\msys64\usr\bin\bash -lc 'pacman --noconfirm -Syuu'
  1. Update MSYS2 (normal)
C:\msys64\usr\bin\bash -lc 'pacman --noconfirm -Syuu'
  1. Install the MinGW-w64 toolchain along with the Clang/LLVM toolchain
C:\msys64\usr\bin\bash -lc 'pacman --noconfirm -Syu --needed base-devel vim nasm mingw-w64-ucrt-x86_64-toolchain mingw-w64-x86_64-toolchain mingw-w64-i686-toolchain mingw-w64-ucrt-x86_64-clang mingw-w64-x86_64-clang mingw-w64-clang-x86_64-toolchain'
  1. Preserve the current working directory
$env:CHERE_INVOKING = 'yes'
  1. Set environment to use UCRT
$env:MSYSTEM = 'UCRT64'
  1. Invoke build tools
C:\msys64\usr\bin\bash -lc 'gcc --version && clang --version'

References

  1. Windows 11 Enterprise
  2. How to install Linux on Windows with WSL
  3. Manual installation steps for older versions of WSL
  4. Set up a WSL development environment
  5. Mingw-w64
  6. Windows Environment Setup for Tradecraft Garden and Crystal Palace
  7. MSYS2
  8. Using MSYS2 in CI
  9. Using GCC with MinGW
  10. Cygwin64 & MinGW-w64 (for Windows)
  11. Installation using MSYS2 and the MinGW Compilers
  12. MSYS2-Introduction
  13. MSYS2 development environment for Windows
  14. How to install gcc and clang on Windows using MSYS
  15. Install gcc compiler on Windows with MSYS2 for C/C++
  16. Ubuntu on WSL
  17. Windows Terminal
  18. Getting Started with Clang and Visual Studio Code on Windows with MSYS2 and MinGW-w64
  19. Understanding the different flavors of Clang C and C++ compilers in Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment