Compiling under VS2008
In this tutorial you will learn how to get the Source SDK up and running with Microsoft Visual Studio 2008. There are several things you're going to have to do to get it working.
Creating a New Source Mod
If you haven't already, you need to create a new Source mod. The Create a Mod tutorial goes over in detail how to do this.
Modifying Files - Migrating From VS2005
To do all of this in a non-destructive way, we must copy our VS2005 files and make a new solution. If you've just created your mod, you do not need to make copies of the files mentioned below.
- Copy
src/Game_HL2MP-2005.sln
and rename the copy toGame_HL2MP-2008.sln
. - Copy
src/cl_dll/client_hl2mp-2005.vcproj
and rename the copy toclient_hl2mp-2008.vcproj
. - Copy
src/dlls/server_hl2mp-2005.vcproj
and rename the copy toserver_hl2mp-2008.vcproj
.

Game_HL2MP-2005.sln
, game\client\client_hl2mp-2005.vcproj
and game\server\server_hl2mp-2005.vcproj
and replace 2005 with 2008.You'll now have created a new project to work with. This is important, as you don't want to go around messing up your entire SDK installation if you mess up. With that done, we can now go ahead and modify our setup.
- Open the newly created
Game_HL2MP-2008.sln
in a text editor. - You should see 2 strings,
cl_dll\client_hl2mp-2005.vcproj
anddlls\server_hl2mp-2005.vcproj
. Change the 2005 in both of them to 2008.

Upgrading the Project
- Open
Game_HL2MP-2008.sln
in Visual Studio 2008. You will be prompted to upgrade the project files. - At the first section of the upgrade process, you are asked if you want to create a backup before converting.
- We want to select "No". Wait for the conversion process to complete, then press the Finish button. You should now automatically launch into your newly converted solution.
We don't need to backup anything because we did a better manual backup ourselves. It's OK if the conversion process tells you that it complied with a few warnings, as this is normal. This SDK was originally meant for VS2005, so there's bound to be some problems.
Installing the DirectX SDK
For creating new shaders you will need the MS DirectX SDK (March 2008). Once installed, follow the below instructions below to incorporate it with your project.
- In VS2008 Go to Tools - Options: Projects and Solutions - VC++ Directories
- Select "Include files" and add "...\Microsoft DirectX SDK (March 2008)\Include"
- Select "Library files" and add "...\Microsoft DirectX SDK (March 2008)\Lib\x86"
- In the Solution Explorer right click 'client_hl2', and select Properties.
- In the client_hl2 properties window, navigate to Linker - Input
- Select the 'Additional Properties' row and click the '...' on the right hand side of the row
- If there is already an entry here, take a new line after it (a space will suffice if you cannot create a new line), and type ' user32.lib ' without the quotes.
- Repeat these steps for 'server_hl2'
Other Important Changes
Some changes must be made to before a compiling:
The compiler encounters this bug: http://developer.valvesoftware.com/cgi-bin/bugzilla/show_bug.cgi?id=214. This is the fix:
- Inside
c_vguiscreen.cpp
, locate the following line:
dist = c_x / tan( M_PI * scaled_fov / 360.0 ); This is line 348 in stock OB HL2DM code.
- Is replaced with:
float dist_denom = tan( M_PI * scaled_fov / 360.0f ); dist = c_x / dist_denom;
The solution can now be compiled in Release, but more changes are required for a Debug compile:
- In the solution explorer, right click on Client (HL2) and select Properties.
- Navigate to Configuration Properties > C/C++ > General
- Change Debug Information Format from "Program Database for Edit & Continue (/ZI)" to "Program Database (/Zi)"
- Navigate to Configuration Properties > C/C++ > Code Generation
- Change Runtime Library from "Multi-threaded Debug (/MTd)" to "Multi-threaded (/MT)"
- Navigate to Configuration Properties > Linker > Input
- Change Ignore Specific Library from "libc;libcd;libcmt" to "libc;libcd;libcmtd"
- Click OK to apply the changes and close the properties window
- repeat these steps for the Server (HL2) project
Finally, a small piece of code must be commented out:
- Inside
memoverride.cpp
, locate the following block found at line 727 in stock OB code:
void __cdecl _invalid_parameter_noinfo(void) { Assert(0); }
- Comment out this routine:
//void __cdecl _invalid_parameter_noinfo(void) //{ // Assert(0); //}
Compile the Client project before the Server project to avoid errors. The SDK installation should now be fully operational. Warnings may still appear, but there shouldn't be any more errors on the first build if these steps are followed. It is recommended to build now while the installation is still fresh. If errors are still occuring, make sure that all the steps were followed correctly. Also, make sure that you add -allowdebug to the mods launch options in Steam, or you will get an error when you start the game with a debug build.