This article's documentation is for anything that uses the Source engine. Click here for more information.

Setting up Source SDK 2013 - Multiplayer (TF2 branch)

From Valve Developer Community
Revision as of 13:08, 8 March 2025 by Shepard62700FR (talk | contribs) ([Windows] Remove C++ MFC component requirement for the launcher, the SDK has been updated fairly recently to remove such dependency)
Jump to navigation Jump to search
English (en)Deutsch (de)Español (es)한국어 (ko)Português do Brasil (pt-br)Русский (ru)中文 (zh)Translate (Translate)

edit
For setting up and compiling the Singleplayer SDK, see see this page.
Broom icon.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
Needs to be completely rewritten to account for public Team Fortress 2 SDK release.
For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.

Key points

  • If you want to create a simple, content-based mod, see this fully-compiled template.
  • Unlike Source SDK 2013 SP or legacy MP branch, macOS macOS (OS X) are no longer officially supported by Valve.

Setting Up (All Platforms)

Setting up the Source SDK Base

Install Source SDK Base 2013 Multiplayer from your Steam Steam library, you can use the search function or enable "Tools" in the filters, or from the links below:

Getting the code

Method 1: Using the GitHub Desktop client (Windows)

  1. Download and install the GitHub Desktop client
  2. Open the Source SDK Git repository and click "Clone to desktop"
Note.pngNote:Since the February 2025 TF2 SDK release, the multiplayer version of the source code will be cloned by default. Use the singleplayer branch if you are developing for the older SDK 2013 SP branch. On older versions of the SDK 2013 source code, there will be two distinct directories for both multiplayer (mp) and singleplayer (sp).

Method 2: Using the command line (Windows/Linux)

  1. Download and install the Git CLI. Linux Linux users can download it with their distro's package manager (APT, Aptitude, DNF, Pacman, Synaptic...). Windows Windows users can download git here.
  2. Open the terminal/command prompt and run this command if you want the multiplayer branch:
git clone https://github.com/ValveSoftware/source-sdk-2013.git
Or, run the following command to clone the singleplayer branch:
git clone -b singleplayer https://github.com/ValveSoftware/source-sdk-2013.git

Setting up (Platform Specific)

Windows Windows

Step One: Installing requirements

You will need to install Visual Studio 2022. You don't need a Microsoft account to download the software but you may be prompted to log in with one when launching the software.

During installation, Visual Studio Installer will ask you which workloads you want to install. You don't need to install everything, make sure that the "Desktop development with C++" workload is ticked otherwise your Visual Studio installation won't be able to do anything C/C++ related.

In terms of components, you will need:

  • C++ core features (you can't untick that one).
  • Latest version of "MSVC++ v143 - VS 2022 x64/x86 build tools" (don't confuse with ARM ones, no need to grab "special versions" like the Spectre mitigated).
  • The latest version of the Windows 10 or 11 SDK (for Windows 10, SDK build 10.0.19041.1; for Windows 11, 10.0.26100.1)
  • Only if you want to support VScript: the latest version of Python 3 (acquired from the official website or via the Microsoft Store), make sure it's in your "PATH" environment variable as well.

Step Two: Compiling the Source SDK and preparing project files

  1. Navigate to 🖿<path-to-git>\src\ and run createallprojects.bat. This will run Valve Project Creator which will create all projects and the solution for the game binaries (client, server...) as well as utilities (VBSP, qc_eyes...)
  2. Open everything.sln.
  3. Select the everything solution, located under the Solution Explorer list, then from the middle menu, right next to the Auto drop down menu (the properties box/pane under the solution explorer), change Debug to Release.
  4. Right Click on the everything solution, then select Build Solution.
Warning.pngWarning:When compiling on Windows 10 and 11 make sure you have unchecked "Use Unicode UTF-8 for worldwide language support". In order to disable it go to "Control Panel\Clock and Region", then click "Region" then "Administrative" tab and "Change system locale"

For those who made the choice of not installing Python at the previous step, you will get compile errors when building the server binary because Python scripts that's supposed to generate some C/C++ files required by VScript couldn't be run due to the missing interpreter. The first part of the fix is to open src/game/server/server_base.vpc with the text editor of your choice and comment the entire $CustomBuildStep "nut" section. Re-run VPC (createallprojects.bat), if Visual Studio was opened and says that things changed outside of the editor, click the "Discard" button so that it reload the local changes made by VPC. Re-select "Debug" or "Release" configuration, compile again, the remaining C/C++ errors can be fixed by commenting the code.

Note.pngNote:
  • If something fails at the end, then simply rebuild the solution.
  • The client.dll is going to be generated in <path-to-git>\src\game\client\Release_mod_hl2mp and <path-to-git>\src\game\client\Release_mod_tf
  • The server.dll is going to be generated in <path-to-git>\src\game\server\Release_mod_hl2mp and <path-to-git>\src\game\server\Release_mod_tf

Optional Steps

These steps are not required for compiling the game DLLs, these are only prerequisites for compiling these specific projects:

Building the shaders
See Source SDK 2013: Shader Authoring.
qc_eyes
  1. Download and install the Multibyte MFC Library.
Note.pngNote:The Multibyte MFC Library add-on doesn't work with Visual Studio Express 2013. The add-on installer doesn't detect Visual Studio Express 2013 as an install because Visual Studio Express 2013 doesn't support MFC.
phonemeextractor
  1. Download a ZIP of the Speech SDK
    Note.pngNote:Microsoft has removed the Speech SDK download page. The link above will download a ZIP of the SDK's contents, including code fixes made by the SDK2013CE community that were previously documented on this page.
  2. Extract the ZIP Archive, and copy the sapi51 folder to the <SDKROOT>\src\utils folder.
Note.pngNote:Mounting it now may generate the error unresolved symbol _IID_IspPhoneticAlphabetSelection. This is perhaps because you already had something mounted and the partial build is broken. This issue can be easily fixed by rebuilding the phonemeextractor

Linux Linux ("container" method)

Step One: Introduction

By default, Steam on Linux and everything on top of it (games, apps...) runs through a sand-boxed environment called the Steam Runtime. It is basically a stripped down Ubuntu installation with the necessary stuff (drivers, libraries...) required to run Steam itself and games.

Valve recommends that everything destined to be run on Linux and more specifically Steam is built and running through this runtime. Building "natively" is heavily discouraged as there are no guarantees that the build will be a success (especially with modern C/C++ toolchains) and your mod might not run perfectly.

In the past, Valve used the "chroot environment" technique for the Steam Runtime. However, they changed and recommend the usage of containers based solutions like Podman and Docker. Source SDK 2013's updated code has been compiled with the third version of the Steam Runtime (codenamed "sniper") and we will be doing the same.

Note.pngNote:This guide has been written and tested on an Ubuntu 22.04.4 LTS (Jammy Jellyfish) virtual machine. If you want to use anything else (ArchLinux, Debian, Gentoo, Linux Mint...), you take the responsibility of adapting the instructions and commands as needed (as well as the factor that it might not work due to system differences and such).

Step Two: Requirements

Any operating system capable of running Podman will do the job. Ubuntu has a package so you can easily download it with apt install podman (use apt-get instead if you're working on a CI/CD pipeline or remotely when you don't have a "fancy" terminal).

Note.pngNote:If you're getting "permission denied" while running the command, remember the "magic word" at the beginning: sudo.

Next, you need the Source SDK 2013 source code cloned. It is assumed that a non-modified copy is used, if you need to clone the source code, the instructions are at the top of this page.

Step Three: Building the binaries

All you have to do is run the $SDK_ROOT/src/buildallprojects shell script (you can also cd src first then ./buildallprojects if you prefer), $SDK_ROOT means where you have cloned the source code earlier. By default, you will be building "release" binaries, if you want "debug" binaries instead, simply add debug after buildallprojects (don't forget a space in-between).

If you're getting an error that involves "invalid mount point", open the sdk_container shell script with a text editor and find the --mount arguments of the podman run command. You should see some \" characters lying around, remove those but be careful not to remove the rest.

Another error you might get is about the .ccache folder being missing in your "home" folder. Creating the folder simply fixes it (mkdir $HOME/.ccache).

Binaries should now be built and available assuming everything went fine. If you want to know how the compile process works exactly, look at buildallprojects and sdk_container shell scripts.

Linux Linux ("chroot environment" method)

Warning.pngWarning:The Steam Runtime as a "chroot environment" approach has changed and thus these instructions might not work as intended. Valve heavily encourage the usage of containers based solutions like Docker, Podman and such instead.

For those who insist on using a "chroot environment", then you should check Valve's documentation.

Note.pngNote:Due to the usage of the Steam Client Runtime, a Debian based Linux distribution (Linux Mint, Ubuntu...) is recommended. Arch Linux based distributions (Antergos, Manjaro...) seems to work as well. You can take the risk of trying with another GNU/Linux distribution but keep in mind that you will have to adapt the commands and this tutorial may fail.

Step One: Getting the basic C/C++ development tools

You should already have these, but to be sure, you can run the following command in a terminal:

sudo apt-get install build-essential

AMD64 (64 bits) users will need to download and install additional packages to target the i386 (32 bits) architecture, this can be done with this command in a terminal:

sudo apt-get install gcc-multilib g++-multilib

If you are using an Arch-based distribution, use this command instead:

sudo pacman -S base-devel gcc dpkg

Step Two: Preparing the Source SDK 2013

Assuming you have already cloned the Source SDK 2013 through Git (or downloaded the ZIP file), just run the following commands (by replacing [SDK_ROOT] by the location of the Source SDK 2013, [GAME] by "sp" or "mp" depending on your mod and [SCRIPT] by either "./createallprojects" or "./creategameprojects"), go into :

cd [SDK_ROOT]/[GAME]/src
[SCRIPT]
Note.pngNote:If you get an error that says "Permission denied" when running the script, go into the devtools/bin folder and allow everything to run as an executable. Then, inside of that folder go into the folder called "linux" and set the ccache file to run as an executable. You can set files to run as executables by right-clicking them in your file manager, clicking the Permissions tab then clicking "Allow this file to run as a program".
Setting executable permissions.png

Depending on the script you ran, you will have a master Makefile called games.mak or everything.mak that will be generated in the src folder.

Step Three: Downloading, installing, setting up the Steam Client Runtime

The Steam Client Runtime will help you guarantee compatibility with most GNU/Linux distributions. It is recommended to install it in "/valve/steam-runtime", if you don't like this and wish to install the Steam Client Runtime elsewhere: symbolic link is your friend. We are going to assume you want to do the first option. Run the following commands in a terminal, make sure to replace "[USER]" by your login and "[GROUP]" by your group name:

cd /
sudo mkdir valve
cd valve
sudo wget https://media.steampowered.com/client/runtime/steam-runtime-sdk_latest.tar.xz
sudo tar xvf steam-runtime-sdk_latest.tar.xz
sudo mv steam-runtime-sdk_2013-09-05 steam-runtime
sudo chown <USER>:<GROUP> * -R
Note.pngNote:If you are having trouble with the chown command, change <GROUP> to be the same as <USER>.

Run the "./setup.sh" script in the "steam-runtime" directory, select "All" architectures if you're running on 64 bit, else select the "i386" architecture, say "Yes" to everything related to updates.

Before compiling the SDK, you have to run the sandbox (chroot environment), this is done by running the "./shell.sh --arch=i386" script.

Step Four: Time to compile

Note.pngNote:If you're on Arch Linux, you'll have to install the dpkg package to compile the game.

In a terminal (like always), "cd" into the "sp" (singleplayer) or "mp" (multiplayer) directory of the SDK and the "src" directory, just run the following command to compile (replace [MAKEFILE] by "games.mak" or "everything.mak" depending on the one available to you):

make -f [MAKEFILE].mak

If everything went well, you should have the "client.so" and "server.so" files in the "game" directory to load with the appropriate Source SDK Base 2013. You can get more instructions on using the Steam Client Runtime by reading the "README.txt" file in the installed runtime directory.

Note.pngNote:
  • If you get another error that something in the "devtools" folder cannot be accessed or says permission denied, allow everything in the devtools folder to run as a program like earlier in the tutorial.
  • If you have an error about "objcopy", edit the "devtools/gendbg.sh" file and change the "OBJCOPY" variable so it points to the default "objcopy" program, usually found at 🖿/usr/bin/objcopy.
  • If you extracted Steam Runtime in directory other than 🖿/valve/steam-runtime, specify STEAM_RUNTIME_PATH environment variable specifying path to extracted runtime before running make.

Setting up on Steam

See Setup mod on steam.

Other information

Adding new files with the Valve Project Creator

  1. Add instructions on how to here.
  2. Open hl2.vpc with a text editor and edit this line or something.

VPC generates project files for all of the platforms that the SDK supports, so if you want to add files to your project in a way that will allow you to easily build on other platforms, consider using VPC. For example, to add a file to a multiplayer game, you could add a line to src/game/client/client_hl2mp.vpc.

Directory structure

  • game - Runtime files for the mods themselves. Any mod content will go in here.
  • src - All the source code for that kind of mod. The root of the src directory contains .sln or root level .mak files for building the source.
    • common - A few files used by the server and client DLLs
    • devtools - Scripts and utilities that are used to build the source. These are called by the makefiles and projects and you probably won't need to interact with them directly.
    • game - All of the source code for the DLLs.
      • client - Code used by client.dll (or client.dylib or client.so). There are also game-specific directories under here.
      • server - Code used by server.dll. There are also game-specific directories under here.
      • shared - Code used by both client.dll and server.dll.
    • gcsdk - A couple of tools used to build the DLLs.
    • lib - Binary versions of the libraries that the source code depends on. This is also the build target for vgui_controls, tier1, and mathlib.
    • mathlib - Math utilities used by the game.
    • public - Header files for all of the DLLs and libraries that are used by the game. Also includes a few source files.
    • thirdparty - Third party libraries needed to build the source. At the moment this contains only the Google Protocol Buffers (protobuf) library.
    • tier1 - Useful utility classes. Builds into tier1.lib
    • utils - Various development utilities
    • vgui2 - Source code for vgui_controls, which is used by client.dll.

Troubleshooting

Unable to find RegKey for .vcproj files in solutions (Windows)

Or if you don't feel like downgrading to VS2013 you can try this alternative solution and see if works for you.

Warning.pngWarning:Editing the Windows registry is dangerous. Changing something you don't know can break the Windows OS.
Go to the windows registry editing 'regedit.exe' and navigate to:
 HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\10.0\Projects\{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} 
Add the "Projects" and "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" registry keys if they don't already exist.
  1. Once inside, add a string key and name it DefaultProjectExtension.
  2. Right click on it and go into 'Modify'
  3. Set the data to vcproj and click ok.

Once You finish It should look like this:

https://i.imgur.com/aCD4DLV.png

Now try run the .bat again and your .sln file should generate without issue!

Warning.pngWarning:Some systems don't use the
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\
path. You need to check what's the pathing your registry uses. For example, there are cases it's
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WOW6432Node\

MSB8008: Specified platform toolset (v120_xp) or (v120) is not installed or invalid (Windows)

  1. Select all Project Files
  2. Right-click on the file, then choose "Properties"
  3. Choose "Configuration Properties"
  4. Under "Platform toolset" this -> (v100)

(Project->Properties->Configuration Properties->General->Platform toolset = Visual Studio 2010(v100))

Issues with "min" or "max" from Steam Runtime when Compiling on Linux

If you get any issues mentioning "min" or "max" while compiling on Linux, it is because you are including something that references the STL, and Valve's macros for min and max are conflicting with it.

Usually GCC is pretty good about telling you which files in particular are erroring.

Go to those files, and surround the erroneous includes with:

#include "tier0/valve_minmax_off.h"
<your include that uses STL>
#include "tier0/valve_minmax_on.h"

This should allow you to compile. Make sure to only wrap the includes that are using the STL, as other, game-related includes may require the Valve min/max macro defines!

See also