Compiling under VS2008: Difference between revisions
(Added fix for comiling in debug) |
TomEdwards (talk | contribs) (cleanup) |
||
Line 1: | Line 1: | ||
In this tutorial you will learn how to get the [[Source SDK]] | In this tutorial you will learn how to get the [[Source SDK]] to compile under '''Visual Studio 2008''' and '''Visual C++ Express 2008'''. There are several things you're going to have to do to get it working. Before you being, [[Create a Mod|create you mod]]. | ||
{{note|You will still encounter occasional "precompiled header skipped" warnings after following this guide. Don't worry, they're harmless!}} | |||
== | == Upgrade the project files == | ||
Visual Studio will prompt you to upgrade the project files. If you've been working on your mod in a previous version you'll probably want to have it make a backup (you may as well do a full backup yourself though); otherwise you can just do the conversion in-place. | |||
{{ | {{tip|For clarity, you may want to rename the project file from <code>whatever_2005.sln</code> to <code>whatever_2008.sln</code>.}} | ||
== Fix a compiler crash == | |||
The 2008 compiler crashes on '''line 348''' ([[Orange box|OB]] code) of <code>client/c_vguiscreen.cpp</code> ([http://developer.valvesoftware.com/cgi-bin/bugzilla/show_bug.cgi?id=214 bug report here]): | |||
* | |||
dist = c_x / tan( M_PI * scaled_fov / 360.0 ); | |||
Replace it with: | |||
float dist_denom = tan( M_PI * scaled_fov / 360.0f ); | |||
dist = c_x / dist_denom; | |||
== Fix file copying == | |||
Right-click > Properties on the Server and Client projects. You will need to do this for both the Release and the Debug configuration; four times in all. | |||
# Navigate to ''Configuration Properties > Custom Build Step''. | |||
# Click on ''Command Line'', then click on the ... button that appears on the right. | |||
# Replace the contents of the new dialogue with the first code block below. | |||
# Click on ''Outputs'' and paste in the second code block below. | |||
{{warning|Remember to change "client" to "server" in the code blocks below when appropriate, and, of course, to fill in the actual target destination.}} | |||
=== Command Line === | |||
if exist "<YOUR MOD PATH>\bin\client.dll" attrib -r "<YOUR MOD PATH>\bin\client.dll" | |||
copy "$(TargetDir)"client.dll "<YOUR MOD PATH>\bin\" | |||
if exist "<YOUR MOD PATH>\bin\client.pdb" attrib -r "<YOUR MOD PATH>\bin\client.pdb" | |||
if exist "$(TargetDir)"client.pdb copy "$(TargetDir)"client.pdb "<YOUR MOD PATH>\bin\" | |||
=== Outputs === | |||
<YOUR MOD PATH>\bin\client.dll;<YOUR MOD PATH>\bin\client.pdb | |||
== Fix debug compilation == | |||
Right-click > Properties on the Server and Client projects. Making sure that you are working on the Debug configuration (top left of properties dialogue): | |||
# Change ''Configuration Properties > C/C++ > Debug Information Format'' to '''<code>Program Database (/Zi)</code>'''. | |||
# Change ''Configuration Properties > C/C++ > Code Generation > Runtime Library'' to '''<code>Multi-threaded (/MT)</code>'''. | |||
# Change ''Configuration Properties > Linker > Input > Ignore Specific Library'' to '''<code>libc;libcd;libcmtd</code>''' (just an extra 'd' on the end). | |||
Lastly, a function needs commenting out at '''line 727''' ([[Orange box|OB]] code) of <code>server/memoverride.cpp</code>: | |||
void __cdecl _invalid_parameter_noinfo(void) | void __cdecl _invalid_parameter_noinfo(void) | ||
Line 70: | Line 57: | ||
} | } | ||
Get rid of the whole thing. Remember to launch your mod with <code>-allowdebug</code>! | |||
== Disable /Wp64 == | |||
You'll receive warnings about the <code>Wp64</code> option. You can ignore them if you like, but it's a simple matter to sort them out too: right-click > Properties on both the Server and Client projects, then change ''Configuration Properties > C/C++ > Detect 64-bit Portability Issues'' to '''<code>No</code>'''. | |||
== Install the DirectX SDK (for shaders) == | |||
For creating new [[shader]]s you will need the [http://go.microsoft.com/fwlink/?LinkID=112184&clcid=0x409 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' | |||
[[Category:Tutorials]] | [[Category:Tutorials]] | ||
[[Category:Programming]] | [[Category:Programming]] |
Revision as of 09:49, 12 June 2008
In this tutorial you will learn how to get the Source SDK to compile under Visual Studio 2008 and Visual C++ Express 2008. There are several things you're going to have to do to get it working. Before you being, create you mod.

Upgrade the project files
Visual Studio will prompt you to upgrade the project files. If you've been working on your mod in a previous version you'll probably want to have it make a backup (you may as well do a full backup yourself though); otherwise you can just do the conversion in-place.

whatever_2005.sln
to whatever_2008.sln
.Fix a compiler crash
The 2008 compiler crashes on line 348 (OB code) of client/c_vguiscreen.cpp
(bug report here):
dist = c_x / tan( M_PI * scaled_fov / 360.0 );
Replace it with:
float dist_denom = tan( M_PI * scaled_fov / 360.0f ); dist = c_x / dist_denom;
Fix file copying
Right-click > Properties on the Server and Client projects. You will need to do this for both the Release and the Debug configuration; four times in all.
- Navigate to Configuration Properties > Custom Build Step.
- Click on Command Line, then click on the ... button that appears on the right.
- Replace the contents of the new dialogue with the first code block below.
- Click on Outputs and paste in the second code block below.

Command Line
if exist "<YOUR MOD PATH>\bin\client.dll" attrib -r "<YOUR MOD PATH>\bin\client.dll" copy "$(TargetDir)"client.dll "<YOUR MOD PATH>\bin\" if exist "<YOUR MOD PATH>\bin\client.pdb" attrib -r "<YOUR MOD PATH>\bin\client.pdb" if exist "$(TargetDir)"client.pdb copy "$(TargetDir)"client.pdb "<YOUR MOD PATH>\bin\"
Outputs
<YOUR MOD PATH>\bin\client.dll;<YOUR MOD PATH>\bin\client.pdb
Fix debug compilation
Right-click > Properties on the Server and Client projects. Making sure that you are working on the Debug configuration (top left of properties dialogue):
- Change Configuration Properties > C/C++ > Debug Information Format to
Program Database (/Zi)
. - Change Configuration Properties > C/C++ > Code Generation > Runtime Library to
Multi-threaded (/MT)
. - Change Configuration Properties > Linker > Input > Ignore Specific Library to
libc;libcd;libcmtd
(just an extra 'd' on the end).
Lastly, a function needs commenting out at line 727 (OB code) of server/memoverride.cpp
:
void __cdecl _invalid_parameter_noinfo(void) { Assert(0); }
Get rid of the whole thing. Remember to launch your mod with -allowdebug
!
Disable /Wp64
You'll receive warnings about the Wp64
option. You can ignore them if you like, but it's a simple matter to sort them out too: right-click > Properties on both the Server and Client projects, then change Configuration Properties > C/C++ > Detect 64-bit Portability Issues to No
.
Install the DirectX SDK (for shaders)
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'