Jump to content

Installing Source SDK Base 2013 Singleplayer: Difference between revisions

From modding.dev WIKI
Created page with "== Introduction == This tutorial shows how to isntall Source SDK 2013 Singleplayer This guide is written for beginners but includes intermediate tips (VPC, particles.lib, memoverride.cpp, VS registry fixes, and Docker/Linux notes). Screenshots are referenced where helpful (placeholders are included so you can add your own images to your wiki or notes). Sources used: Valve Developer Community (Source SDK 2013 SP, Compiling under VS2022) and the community repo Source-SD..."
(No difference)

Revision as of 21:43, 19 October 2025

Introduction

This tutorial shows how to isntall Source SDK 2013 Singleplayer

This guide is written for beginners but includes intermediate tips (VPC, particles.lib, memoverride.cpp, VS registry fixes, and Docker/Linux notes). Screenshots are referenced where helpful (placeholders are included so you can add your own images to your wiki or notes).

Sources used: Valve Developer Community (Source SDK 2013 SP, Compiling under VS2022) and the community repo Source-SDK-Resources/source-sdk-vs2022.

Prerequisites

  • Basic familiarity with Windows and Visual Studio (opening solutions, building projects).
  • A valid Steam account and Steam client installed.
  • Tools / software:

Tutorial

Overview of approach

There are two main ways to get a usable source tree:

  • Use Valve's original source-sdk-2013 singleplayer repo and manually apply the changes from the community compatibility repo.
  • Clone the community repo "source-sdk-vs2022" which already contains the VS2022-compatible trees (simpler for most users).

This tutorial follows the simpler path (clone source-sdk-vs2022) and also documents the key manual fixes you may need if you start from Valve's repo.

1) Download the source code (community VS2022 repo method)

Recommended: clone the prepatched community repo for easiest results.

Open a terminal (PowerShell or Git Bash) and run:

git clone https://github.com/Source-SDK-Resources/source-sdk-vs2022.git
cd source-sdk-vs2022

This repository contains both sp/ (singleplayer) and mp/ (multiplayer) folders. For this tutorial we will use the sp/ folder. If you instead want to start from Valve's original repo and apply patches:

git clone https://github.com/ValveSoftware/source-sdk-2013.git --branch singleplayer --single-branch
== then merge or manually copy fixes from Source-SDK-Resources/source-sdk-vs2022 ==

2) Prepare the source code (VPC / project generation)

  1. Open a Developer Command Prompt for VS2022 (so MSVC and environment vars are set).
  2. Change directory to the sp src folder:
cd path\to\source-sdk-vs2022\sp\src
  1. Generate the game project files (VPC-generated sln files). The repository already includes VS2022-compatible project files in many cases, but running the script will ensure any machine-specific files are created:
.\creategameprojects.bat
== or to create the Everything solution: ==
.\createallprojects.bat

Notes:

  • If VPC (Valve Project Creator) complains about Visual Studio registry keys (because it expects older VS), either:
    • use the modified VPC bundled in the community repo, or
    • add the legacy registry keys manually (see Troubleshooting section).
  • If you start from Valve's unmodified repo and you run VPC under modern VS, you may be prompted to "upgrade projects". Choose to keep the existing project formats if prompted (do NOT let Visual Studio permanently upgrade the project files unless you know what you're doing). The source-sdk-vs2022 repo avoids this issue.

3) Apply VS2022-specific fixes (if not already present)

If you cloned the community repo, it likely already contains the required fixes (memoverride.cpp, updated vpc scripts, updated project files). If you started from Valve's repo, do the following:

  1. Replace memoverride.cpp with the compatibility version:
  • Download or copy the memoverride.cpp from the community repo:
 https://github.com/Source-SDK-Resources/source-sdk-vs2022/blob/master/mp/src/public/tier0/memoverride.cpp
  • Place it into: sp\src\public\tier0\memoverride.cpp (or the corresponding public\tier0 folder in your tree).
  1. Fix particles.lib symbol conflict:
  • If the linker complains about duplicate _hypot symbol with particles.lib, replace particles.lib with the fixed version from the repo:
 Place the fixed particles.lib into sp\src\lib\public\particles.lib (or the lib\public path used by your build).
  • Alternative: change project link options to allow multiple definitions (not recommended).
  1. Ensure <PlatformToolset> is set correctly inside VPC scripts or project files if you want to use a specific toolset. The community repo typically sets this up for VS2022.

4) First compile (Visual Studio)

  1. Open the generated solution:
  • Open sp\src\games.sln (or everything.sln) in Visual Studio 2022.
  • If you have both "games" and "everything", "games.sln" is the minimal solution to build client/server.
  1. In Solution Explorer set the configuration:
  • Select the "games" solution node, change Configuration from Debug to Release (top toolbar).
  1. Build the solution:
  • Right-click the "games" solution -> Build Solution.
  • Or build specific projects: client, server, shared libs.
  1. If any project fails:
  • Rebuild the failing project (sometimes incremental builds [Build -> Rebuild Solution] clear issues).
  • Look for missing includes (adjust include paths) or missing third-party libraries in sp\src\thirdparty.

Example: Build from command-line using MSBuild:

== From Developer Command Prompt ==
MSBuild.exe games.sln /p:Configuration=Release /m

Expected build outputs (example paths):

  • client.dll (Windows) -> path\to\sp\src\game\client\Release_mod_hl2\client.dll
  • server.dll -> path\to\sp\src\game\server\Release_mod_hl2\server.dll

Note: Names and folders may include mod_episodic variants depending on the VPC-generated project definitions. Check your built project's output directory.

5) Copy built binaries and run the mod

  1. Ensure Steam's Source SDK Base 2013 Singleplayer is installed and set to the "upcoming" beta.
  2. Copy the compiled DLL(s) into the proper location where the game expects them. The simplest workflow for testing locally:
  • Locate the Source SDK Base 2013 Singleplayer install folder:
 SteamLibrary\steamapps\common\Source SDK Base 2013 Singleplayer (path varies per Steam library).
  • Inside the SDK folder the runtime expects mod DLLs in a game's folder; for quick testing you can:
  • Replace the game's existing client/server DLLs with your newly built ones (make a backup first).
  • Or point your mod folder to use the compiled DLLs from your source tree via a local mod config.
  1. Launch Source SDK Base 2013 Singleplayer in Steam.
  • If you copied correct DLLs and the SDK Base branch matches the code (use "upcoming"), the game should load your built client/server.
  • If the game crashes on startup and Visual Studio debugger breaks in engine.dll: ensure you are on the upcoming SDK Base 2013 SP beta in Steam (this is a common cause).

Tip: For game testing, create a dedicated mod folder and a .vpk or content folder to isolate changes instead of overwriting SDK base files.

6) Linux and macOS notes (brief)

  • Linux: Valve recommends building inside Steam Runtime containers (Docker/podman) because older code requires older toolchains. The Steam Runtime "scout" i386 container is commonly used for Source SDK 2013 builds. Steps:
  • Edit mp/src/devtools/makefile_base_posix.mak to set STEAM_RUNTIME_PATH := /usr when using container or change GCC_VER as needed.
  • Use the docker run command shown in Valve docs to mount your src directory and run make inside the container:
sudo docker run -v /absolute/path/to/sp/src:/src --rm -it registry.gitlab.steamos.cloud/steamrt/scout/sdk/i386 bash
cd /src
== then: ==
make -f games.mak
  • macOS: Xcode 5/6 historically supported building the SDK, but modern macOS and Xcode versions will cause 32-bit/ARCHS issues. Use a VM with an older macOS if you need to build there.

Practical examples and snippets

Example: creategameprojects.bat invocation (PowerShell):

PS C:\dev\source-sdk-vs2022\sp\src> .\creategameprojects.bat
== This generates games.sln and other per-game project files ==

Example: common wrapper for includes that conflict with Valve min/max macros (Linux/mac builds):

#include "tier0/valve_minmax_off.h"
#include <vector>   // or other STL header that fails without this wrapper
#include "tier0/valve_minmax_on.h"

Example: replacing memoverride.cpp (illustrative; copy the file from the repo):

== Replace file: ==
copy path\to\source-sdk-vs2022\mp\src\public\tier0\memoverride.cpp path\to\your\sp\src\public\tier0\memoverride.cpp

Screenshot references (add your own images to wiki pages or notes):

  • Screenshot: Visual Studio - games.sln loaded and set to Release (example: File:VS2022_games_solution.png)
  • Screenshot: Steam SDK Base 2013 Singleplayer -> Properties -> Betas -> upcoming selected (File:Steam_upcoming_beta.png)
  • Screenshot: Docker container shell in Steam Runtime "scout" building with make (File:docker_build_scott.png)

Tips and Best Practices

  • Use the community "source-sdk-vs2022" repo when possible — it saves time and contains the common compatibility fixes.
  • Keep your source under version control (your own Git repo) so you can revert patches and track changes.
  • Backup original Valve SDK binaries before replacing them in your Steam install.
  • Use Release configuration for testing actual runtime behavior; Debug builds are useful for debugging but are slower and require different runtime dependencies.
  • If you modify VPC scripts, commit those changes separately — they may be unique to your machine.
  • Avoid adding spaces in SDK root path (e.g., C:\Dev\SourceSDK) — many scripts expect simple paths and break on spaces. If you must, quote paths carefully.
  • If you rely on third-party libs, keep toolchains consistent between your mod and the libraries (especially on Linux).
  • If you get min/max macro conflicts, use the tier0 valve_minmax_off/on headers around STL includes.

Troubleshooting (common issues and solutions)

VPC fails due to missing Visual Studio registry keys

  • Symptom: VPC/.bat fails with errors about .vcproj or missing registry keys.
  • Fix: Use the modified VPC from the community repo or add the expected registry keys (advanced). Example registry path noted in community docs:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0\Projects\{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}
== Add string DefaultProjectExtension = "vcproj" ==

Warning: editing the registry is risky — back it up first.

MSB8008: Specified platform toolset is not installed

  • Symptom: Visual Studio reports v120_xp or v120 toolset missing.
  • Fix: Edit project files or VPC script to use a toolset you have (v142 for VS2019, v143 for VS2022) or install the older toolset if needed. The community repo configures this for VS2022.

Linker conflicts with particles.lib (_hypot duplicate)

  • Symptom: Linker error about multiple definitions (_hypot).
  • Fix: Replace particles.lib with the fixed version from the community repo, or adjust link settings (not recommended). See source-sdk-vs2022 for patched library.

Build errors in memoverride.cpp

  • Symptom: Errors in tier0 memoverride code when compiling under modern MSVC.
  • Fix: Replace memoverride.cpp with the compatibility version provided in source-sdk-vs2022.

Game crashes on startup after copying DLLs

  • Symptom: Two popups regarding "Entry Point Not Found" and debugger breaks in engine.dll.
  • Fix: Make sure you have opted into the "upcoming" beta for Source SDK Base 2013 Singleplayer in Steam. The Singleplayer base must match the built DLL ABI.

min/max macro collisions on Linux

  • Symptom: compile errors mentioning min/max when including STL headers.
  • Fix: Surround the offending includes with:
#include "tier0/valve_minmax_off.h"
#include <header_that_needs_stl>
#include "tier0/valve_minmax_on.h"

Conclusion

You now have the steps needed to set up Source SDK 2013 Singleplayer for development using modern Visual Studio (preferably VS2022) by leveraging the community "source-sdk-vs2022" compatibility repository. Key takeaways:

  • Install VS2022 + Git + Steam SDK Base 2013 SP (opt into upcoming beta).
  • Clone the source-sdk-vs2022 repo (sp folder), run creategameprojects.bat and open games.sln.
  • Replace memoverride.cpp and particles.lib if you have an older Valve tree, or use the prepatched community repo to avoid those issues.
  • Build Release -> copy DLLs into the appropriate SDK Base folder and run via Steam.

Next steps:

  • Start small: add a simple console print or change a client behavior and recompile to validate your workflow.
  • Learn VPC usage to add files cross-platform.
  • Consider exploring Linux container builds if you plan to ship Linux server binaries.

Sources