documents/building-windows.md
This tutorial reads as if you have none of the prerequisites already installed. If you do, just ignore the steps regarding installation.
[!WARNING] If you are trying to compile older builds for testing, do not provide the
--depth 1flag ingit clone. This flag omits the commit history from your clone, saving storage space while preventing you from testing older commits.
Note: ARM64 is not supported! As of writing, it will not build nor run. The instructions with respect to ARM64 are for developers only.
Once you are within the installer:
Desktop development with C++C++ Clang Compiler for Windows and MSBuild support for LLVMGo through the Git for Windows installation as normal
git clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4Open a local folder and select the folder with the shadPS4 source code. The folder should contain CMakeLists.txtYour shadps4.exe will be in C:\path\to\source\Build\x64-Clang-Release\
If your default IDE is VSCode, we have a fully functional example for that as well.
The main reason we use clang19 is because that version is used in CI for formatting.
Add LLVM to the system PATH for all usersAdd CMake to the system PATH for all usersC:\ninja and add it to the system PATH for all users
Search with Start Menu -> Environment Variables -> System Variables -> Path -> Edit -> New -> C:\ninjagit --version
# git version 2.49.0.windows.1
cmake --version
# cmake version 4.2.3
ninja --version
# 1.13.2
clang --version
# clang version 19.1.1
MSVC - Windows SDK and install (you don't need to install an IDE).vsconfig file:{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
"Microsoft.Component.MSBuild",
"Microsoft.VisualStudio.Component.CoreBuildTools",
"Microsoft.VisualStudio.Workload.MSBuildTools",
"Microsoft.VisualStudio.Component.Windows10SDK",
"Microsoft.VisualStudio.Component.VC.CoreBuildTools",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
"Microsoft.VisualStudio.Component.Windows11SDK.26100",
"Microsoft.VisualStudio.Component.TestTools.BuildTools",
"Microsoft.VisualStudio.Component.VC.ASAN",
"Microsoft.VisualStudio.Component.TextTemplating",
"Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
"Microsoft.VisualStudio.Workload.VCTools"
],
"extensions": []
}
Save the file as `.vsconfig` and run the following command:
%userprofile%\Downloads\vs_BuildTools.exe --passive --config ".vsconfig"
Be carefull path to vs_BuildTools.exe and .vsconfig file.
This will install the necessary components to build shadPS4.
shadps4/
├── shared (shadps4 main files)
└── shadps4.code-workspace
shadps4.code-workspace{
"folders": [
{
"path": "shared"
}
],
"settings": {
"cmake.generator": "Ninja",
"cmake.configureEnvironment": {
"CMAKE_CXX_STANDARD": "23",
"CMAKE_CXX_STANDARD_REQUIRED": "ON",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"cmake.configureOnOpen": false,
"C_Cpp.intelliSenseEngine": "Disabled",
"clangd.arguments": [
"--background-index",
"--clang-tidy",
"--completion-style=detailed",
"--header-insertion=never",
"--compile-commands-dir=Build/x64-Clang-Release"
],
"editor.formatOnSave": true,
"clang-format.executable": "clang-format"
},
"extensions": {
"recommendations": [
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cmake-tools",
"xaver.clang-format"
]
}
}
cd shadps4\sharedgit clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4 .or fork link
git submodule update --init --recursive
These plugins are suggested in the workspace file above and are already configured.
File > Open workspace from file > shadps4.code-workspaceYour shadps4.exe will be in shadps4\shared\Build\x64-Clang-Release\
[!IMPORTANT] Building with MSYS2 is broken as of right now, the only way to build on Windows is to use Option 1: Visual Studio 2022 or Option 2: VSCode with Visual Studio Build Tools.
Go through the MSYS2 installation as normal
If you are building to distribute, please omit -DCMAKE_CXX_FLAGS="-O2 -march=native" within the build configuration step.
Normal x86-based computers, follow:
pacman -Syu, let it complete;pacman -S --needed git mingw-w64-x86_64-binutils mingw-w64-x86_64-clang mingw-w64-x86_64-cmake mingw-w64-x86_64-rapidjson mingw-w64-x86_64-ninja mingw-w64-x86_64-ffmpeggit clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4cd shadPS4cmake -S . -B build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"cmake --build build./build/shadPS4.exeARM64-based computers, follow:
pacman -Syu, let it complete;pacman -S --needed git mingw-w64-clang-aarch64-binutils mingw-w64-clang-aarch64-clang mingw-w64-clang-aarch64-rapidjson mingw-w64-clang-aarch64-cmake mingw-w64-clang-aarch64-ninja mingw-w64-clang-aarch64-ffmpeggit clone --depth 1 --recursive https://github.com/shadps4-emu/shadPS4cd shadPS4cmake -S . -B build -DCMAKE_C_COMPILER="clang.exe" -DCMAKE_CXX_COMPILER="clang++.exe" -DCMAKE_CXX_FLAGS="-O2 -march=native"cmake --build build./build/shadPS4.exeThese builds may not be easily copyable to people who do not also have a MSYS2 installation. If you want to distribute these builds, you need to copy over the correct DLLs into a distribution folder. In order to run them, you must be within the MSYS2 shell environment.