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

Source SDK 2013

From Valve Developer Community
Jump to: navigation, search

English (en)Deutsch (de)한국어 (ko)português do Brasil (pt-br)русский (ru)español (es)中文 (zh)
Edit
Icon-broom.png
This article or section needs to be cleaned up to conform to a higher standard of quality because:
OS X instructions are incomplete, the files cannot be possibly built due to the Windows dependencies, they need to be re-written from scratch. Shader build instructions are poorly written, not crossplatform friendly. Valve Project Creator instructions are incomplete.
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

Note.pngNote:The Source SDK uses the Valve Project Creator in order to generate the required platform specific files.
Note.pngNote:If you want to create a simple, content-based mod, see this fully-compiled template.
Note.pngNote:You can always edit code files with Notepad ++ or a similar program, and then compile under Visual Studio.

Setting Up (All Platforms)

Setting up the Source SDK Base

Install Source SDK Base 2013 (multiplayer or singleplayer depending on your mod) from your steam library, you can use the search function or enable "Tools" in the filters, or from the links below:

Getting the code

Method one: Using the GitHub Desktop client (Windows/OS X)

  1. Download and install the GitHub Desktop client
  2. Open the Source SDK git repo and click "Clone to desktop"

Method two: Using the command line (Windows/OS X/Linux)

  1. Download and install the git CLI. Linux users can download it with their distro's package manager (APT, Aptitude, DNF, Pacman, Synaptic...). Mac's users can download git here.
  2. Open the terminal/command prompt and run this command:
git clone https://github.com/ValveSoftware/source-sdk-2013.git

Method three: Downloading the ZIP archive

Note.pngNote:You will need to update the code manually whenever changes are committed to the repo

Download from here

Setting up (Platform Specific)

Source SDK 2013 on Windows Windows

Step One: Installing Visual Studio

Note.pngNote:Although Source SDK 2013 currently does NOT compile with Visual Studio 2015 (bug report) you can still use up to VS 2022 as IDE and compile the code as long as the VS 2013 Project format is used.
Just install both VS 2013 and 2015 (or newer) , open the solution in VS 2015, and skip the dialog where VS 2015 tries to upgrade your projects.

You can also compile without Visual Studio, or using a different version.

As of 2021, Microsoft has removed the packages needed for the web-based VS2013 installer to work. To install VS2013 using the ISO method, follow these steps.

Prerequisites:

  1. Microsoft account
  2. Program to extract or mount ISO files, such as the free 7-Zip, WinCDEmu, unless your Operating System (such as Windows 8 or later) natively supports mounting ISOs.

Install steps:

  1. Download the ISO of Visual Studio Community 2013 from here
Note.pngNote: You may also download an official version of Visual Studio 2013 Professional or other from the official Visual Studio website
  1. Using your ISO extraction program, extract the downloaded ISO somewhere
  2. Run the "vs_community.exe" file in the extracted folder
  3. Follow the prompts in the installer

If at any point you get stuck, you can watch this video.

Step Two: Compiling the Source SDK and preparing project files

  1. Navigate to <path-to-git>\sp\src\ or <path-to-git>\mp\src\ (depending on what type of mod you want to make) and run creategameprojects.bat
  2. (OPTIONAL) You may also run createallprojects.bat in the same directory to create the 'Everything' solution
Note.pngNote:The Everything solution also contains the Game solutions along with other utilities such as VBSP and qc_eyes.
  1. Open games.sln for the desired mode (Singleplayer or Multiplayer).
  2. Select the games 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.
  3. Right Click on the games 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"


Notes

Note.pngNote:If something fails at the end, then simply rebuild the solution.
Note.pngNote:The client.dll is going to be generated in <path-to-git>\sp\src\game\client\Release_mod_hl2 and <path-to-git>\sp\src\game\client\Release_mod_episodic
Note.pngNote:The server.dll is going to be generated in <path-to-git>\sp\src\game\server\Release_mod_hl2 and <path-to-git>\sp\src\game\server\Release_mod_episodic
Note.pngNote:The current Singleplayer branch will crash on startup, unless you are using the beta-branch called "upcoming" of the Source SDK Base 2013. In Steam, go to Tools > Source SDK Base 2013 Singleplayer, right click > Properties > Betas > choose "upcoming" to opt into the beta. Without the beta, you get two popups about "Entry Point Not Found" in hl2.exe, and then the debugger breaks on engine.dll

Step Three (optional): Building the shaders

See Source SDK 2013: Shader Authoring.

Optional Steps

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

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>\sp\src\utils folder or <SDKROOT>\mp\src\utils folder depending on your mod.
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

Source SDK 2013 on macOS macOS (OS X)

Step One : Requirements

  1. Get OS X Mavericks (or newer) which is capable of running on a Virtual Machine.
  2. Install Xcode 5.0.2 (requires an Apple Developer ID account).
  3. You will also need to have the "Command Line Tools" installed. You can find this in Xcode Preferences -> Downloads -> Components window.
Note.pngNote:You should be able to use Xcode 6.4 on OS X 10.10 Yosemite and OS X 10.11 El Capitan as well.
Note.pngNote:If you're trying to use a later macOS/Xcode combination, you should modify the src/devtools/base.xcconfig file in order to generate more compatible project settings (the most important one being SDKROOT at the end).
Warning.pngWarning:If you are using macOS Catalina macOS Catalina or higher, building the Source SDK 2013 source code will be highly complicated due to Apple deprecated the 32-bit architecture, aswell as Source SDK 2013 code, by default, does not have support for ARM architecture (used in M1, M2 or newer Apple silicon Macs). You will get an error/warning about updating the ARCHS variable in Xcode to be something else than i386.

Step Two : Generating the Xcode projects

Run the following scripts to generate project files.

Note.pngNote:You'll only need to run the scripts for the base gamemodes you're creating a mod for; sp for single player and mp for multiplayer
cd <SDK_ROOT>/sp/src
./createallprojects
./creategameprojects
cd <SDK_ROOT>/mp/src
./createallprojects
./creategameprojects

games.xcodeproj and everything.xcodeproj will be generated in the src folder.

Step Three : Building

To compile the tools, server and client libraries open everything.xcodeproj and games.xcodeproj in Xcode and build the projects (Product -> Build).

Note.pngNote:Using a more modern environment will yield some errors when compiling.

Step Four : Binaries

When successfully built, client.dylib and server.dylib will be created and ready to use with the desired Source SDK Base 2013 branch (singleplayer or multiplayer).

Source SDK 2013 on Linux Linux

Blank image.pngTodo: Add instructions for building with the latest Steam Runtime.
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.
Note.pngNote: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.
Note.pngNote: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:

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