Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/sr2echa/TF2-Source-Code/llms.txt

Use this file to discover all available pages before exploring further.

Before you can compile anything, you need to understand VPC — Valve’s Project Creator. VPC reads .vpc script files scattered across the source tree and generates native project files for your platform: Visual Studio .sln / .vcxproj on Windows, and Makefile files on Linux. You never edit the generated files directly; you edit the .vpc scripts and regenerate.
Some files in this repository were compressed to comply with GitHub’s upload size limit and will not link or run correctly as-is. Affected files include pre-built libraries and platform runtimes:
  • lib/common/x64/2015/debug/cryptlib.lib
  • lib/public/linux32/libcef.so.dbg
  • tools/runtime/linux/steamrt_scout_amd64.tar.xz
  • tools/runtime/linux/steamrt_scout_i386.tar.xz
This source drop is provided for reference and study. Building a functional game binary requires the full, uncompressed versions of these files plus additional Valve-internal dependencies.

What VPC is

VPC (Valve Project Creator) is a purpose-built meta-build tool. It reads .vpc project scripts and .vgc group/configuration files, then emits platform-native build files. A single .vpc file can produce output for Visual Studio on Windows and GNU Make on Linux from the same source description. You run VPC from the tf2_src/ directory using the binary at devtools/bin/vpc.exe:
devtools\bin\vpc.exe [flags] +<group_or_project> /mksln <solution_name>.sln
Key flags:
FlagMeaning
/2013Target Visual Studio 2013 (v120 toolset)
+everythingInclude every project defined in groups.vgc
+gameInclude only the runtime game group (client, server, engine, etc.)
+dedicatedInclude the dedicated server group
/mksln <name>Emit a .sln wrapping all generated .vcxproj files
@all_64Also generate 64-bit targets where applicable

The createallprojects.bat entry point

The root of tf2_src/ contains a one-liner batch file that generates a solution containing every project in the tree:
devtools\bin\vpc.exe /2013 +everything /mksln everything.sln
Running this on Windows produces everything.sln alongside individual .vcxproj files for each project. Open everything.sln in Visual Studio 2013 or later to browse and build the full tree.
If you only want to work on the game DLLs, use +game instead of +everything. The game group defined in vpc_scripts/groups.vgc includes client, server, engine, tier0tier3, materialsystem, vphysics, and about 40 other runtime projects — without all the tools and Maya plug-ins pulled in by +everything.

Build walkthrough

1

Install prerequisites

Windows: Install Visual Studio 2013 (or a later version with the v120 toolset). The VPC /2013 flag targets the v120 platform toolset.Linux: Install the Steam Runtime Scout toolchain. The tarballs are at tools/runtime/linux/steamrt_scout_amd64.tar.xz and steamrt_scout_i386.tar.xz. Extract them and set up your build environment per Valve’s Linux SDK instructions in linux_sdk/.
2

Generate project files

Open a command prompt in tf2_src/ and run:
devtools\bin\vpc.exe /2013 +game /mksln game.sln
VPC reads vpc_scripts/groups.vgc to resolve the game group, then reads each project’s .vpc file, applies the base scripts from vpc_scripts/, and emits .vcxproj files next to each source directory.On Linux, omit /mksln and VPC emits Makefile files instead:
devtools/bin/vpc +game
3

Open the solution (Windows)

Open game.sln in Visual Studio. You will see projects grouped by directory. The two most important ones for game-logic work are:
  • Client (TF)game/client/client_tf.vpc
  • Server (TF)game/server/server_tf.vpc
4

Select a build configuration

Visual Studio exposes two standard configurations:
ConfigurationOptimisationDebug info
DebugNone (/Od)Full PDB, assertions enabled
ReleaseFull (/O2)Minimal PDB
The per-configuration compiler settings live in the vpc_scripts/ base scripts. For example, source_dll_win32_debug.vpc sets:
$Configuration "Debug"
{
    $Compiler
    {
        $Optimization    "Disabled (/Od)"
        $RuntimeLibrary  "Multi-threaded Debug DLL (/MDd)"
    }
}
And source_dll_win32_release.vpc enables optimisation and sets NDEBUG.
5

Build the target DLL

Right-click Client (TF) or Server (TF) in Solution Explorer and choose Build. The output DLLs land in a game/ output directory alongside the TF2 game files.On Linux:
make -f client_tf.mak CFG=release
make -f server_tf.mak CFG=release

How individual .vpc files work

Each .vpc file describes one buildable project. The TF game DLLs follow a common pattern: a thin game-specific .vpc that $Includes one or more base scripts, then adds its own source files.

server_tf.vpc

$Macro SRCDIR    "..\.."
$Macro GAMENAME  "tf"

$Include "$SRCDIR\game\server\server_base.vpc"
$Include "$SRCDIR\game\server\server_econ_base.vpc"
$include "$SRCDIR\game\shared\tf\tf_gcmessages_include.vpc"
$Include "$SRCDIR\game\server\nav_mesh.vpc"

$Configuration
{
    $Compiler
    {
        $AdditionalIncludeDirectories  "$BASE;$SRCDIR\game\shared\hl2;.\tf;.\tf\vgui;..."
        $PreprocessorDefinitions       "$BASE;TF_DLL;ENABLE_GC_MATCHMAKING;GLOWS_ENABLE;USE_DYNAMIC_ASSET_LOADING;NEXT_BOT"
    }
}

$Project "Server (TF)"
{
    $Folder "Source Files"
    {
        $File "tf\tf_player.cpp"
        $File "tf\tf_player.h"
        // ... hundreds more TF-specific files
    }
}
The $BASE token in $PreprocessorDefinitions appends to whatever the included base script already defines, rather than replacing it.

client_tf.vpc

$Macro SRCDIR    "..\.."
$Macro GAMENAME  "tf"

$Macro WORKSHOP_IMPORT_ENABLE  $WINDOWS

$Include "$SRCDIR\game\client\client_base.vpc"
$include "$SRCDIR\game\shared\tf\tf_gcmessages_include.vpc"
$Include "$SRCDIR\game\client\client_econ_base.vpc"
$Include "$SRCDIR\vpc_scripts\source_saxxyawards.vpc"
$Include "$SRCDIR\utils\itemtest_lib\itemtest_lib_support.vpc" [$WORKSHOP_IMPORT_ENABLE]

$Configuration
{
    $Compiler
    {
        $PreprocessorDefinitions  "$BASE;TF_CLIENT_DLL;USES_ECON_ITEMS;ENABLE_GC_MATCHMAKING;GLOWS_ENABLE;USE_DYNAMIC_ASSET_LOADING;SIXENSE;VOTING_ENABLED;NEXT_BOT"
        $PreprocessorDefinitions  "$BASE;WORKSHOP_IMPORT_ENABLED" [$WORKSHOP_IMPORT_ENABLE]
    }
}
Note the [$WORKSHOP_IMPORT_ENABLE] conditional: Steam Workshop item import and the itemtest_lib dependency only build on Windows, gated by the $WINDOWS macro.

Platform differences

  • Compiler: MSVC v120 (Visual Studio 2013 toolset)
  • Output: client.dll, server.dll
  • Base scripts: source_dll_win32_base.vpc, source_dll_win32_debug.vpc, source_dll_win32_release.vpc
  • The [$WINDOWS] conditional in .vpc files enables Windows-only code paths (DirectX, WinSock, Steam Workshop import)
  • Pre-built import libraries live under lib/public/ and lib/common/

The vpc_scripts/ directory

The vpc_scripts/ directory contains base scripts that are $Included by almost every project in the tree. You rarely need to edit these unless you are changing global compiler flags or adding a new dependency across all projects.
FilePurpose
source_dll_base.vpcCommon settings for all DLL projects
source_dll_win32_base.vpcWindows DLL: entry point, subsystem
source_dll_win32_debug.vpcWindows Debug config overrides
source_dll_win32_release.vpcWindows Release config overrides
source_dll_posix_base.vpcLinux/macOS DLL settings
source_dll_x360_base.vpcXbox 360 DLL settings (legacy)
FilePurpose
source_lib_base.vpcCommon static library settings
source_lib_win32_base.vpcWindows static library settings
source_lib_posix_base.vpcLinux/macOS static library settings
source_exe_base.vpcCommon executable settings
source_exe_win_win32_base.vpcWindows GUI executable settings
source_exe_con_base.vpcConsole (non-GUI) executable settings
source_exe_posix_base.vpcLinux executable settings
FilePurpose
source_win32_base.vpcWin32 platform macros and warning suppressions
source_posix_base.vpcPOSIX platform macros
source_base.vpcTop-level include pulled by nearly all projects
loadaddress.vpcDLL preferred load addresses (Windows)
platform_dirs.vpcPlatform-specific output directory macros
version.vpcBuild version definitions
protobuf_builder.vpcProtobuf code-generation integration
FilePurpose
groups.vgcDefines named groups (game, dedicated, everything, etc.) as lists of project names
projects.vgcMaps every project name to the path of its .vpc file
default.vgcDefault VPC invocation configuration

Key preprocessor defines

The TF game DLLs use preprocessor defines to gate code that belongs to only one side of the client/server split, or to a specific platform:
DefineSet inMeaning
TF_DLLserver_tf.vpcCode is compiling into the server DLL
TF_CLIENT_DLLclient_tf.vpcCode is compiling into the client DLL
GAME_DLLserver_base.vpcGeneric server-side guard (any game)
CLIENT_DLLclient_base.vpcGeneric client-side guard (any game)
USES_ECON_ITEMSclient_tf.vpcEnables the economy / item system
ENABLE_GC_MATCHMAKINGBoth TF VPCsEnables Game Coordinator matchmaking
NEXT_BOTBoth TF VPCsCompiles in the NextBot AI framework
GLOWS_ENABLEBoth TF VPCsEnables outline-glow rendering
WORKSHOP_IMPORT_ENABLEDclient_tf.vpc (Windows only)Enables Steam Workshop item import
NDEBUGRelease configsDisables assertions
In shared source files you will frequently see guards like:
#ifdef GAME_DLL
    // Server-only code
#else
    // Client-only code
#endif
or the shorter forms #ifdef CLIENT_DLL / #ifndef CLIENT_DLL.

Build docs developers (and LLMs) love