Compiling under VS2008: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
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.
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.


== Create a new project ==
== Creating a New Source Mod ==
If you haven't already, you need to create a new SDK project.
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.


* Under the tool section of your steam client, launch the Source SDK.
== Backing Up Files ==
* Click "[[Create a Mod]]".
To do all of this in a non-destructive way, we must copy our VS2005 files and make a new solution. If you have just created your mod, you can skip this step.
* Choose one of the options(in this tutorial I used Hl2MP).
* Select a path to install it to, preferably not in your Steam folders. It's recommend <code>C:/*MODNAMEHERE*</code>, as it'll be easy for you or anyone else to find if you need some files.
 
You should now have a fresh SDK installation in the folder you selected.
 
== Copying files ==
To do all of this in a non-destructive way, we must copy our VS2005 files and make a new solution.


* Copy <code>src/Game_HL2MP-2005.sln</code> and rename the copy to <code>Game_HL2MP-2008.sln</code>.
* Copy <code>src/Game_HL2MP-2005.sln</code> and rename the copy to <code>Game_HL2MP-2008.sln</code>.
* Copy <code>src/cl_dll/client_hl2mp-2005.vcproj</code> and rename the copy to <code>client_hl2mp-2008.vcproj</code>.
* Copy <code>src/cl_dll/client_hl2mp-2005.vcproj</code> and rename the copy to <code>client_hl2mp-2008.vcproj</code>.
* Copy <code>src/dlls/server_hl2mp-2005.vcproj</code> and rename the copy to <code>server_hl2mp-2008.vcproj</code>.
* Copy <code>src/dlls/server_hl2mp-2005.vcproj</code> and rename the copy to <code>server_hl2mp-2008.vcproj</code>.


{{Note|If you are using the Orange box source code, you will need to copy <code>Game_HL2MP-2005.sln</code>, <code>game\client\client_hl2mp-2005.vcproj</code> and <code>game\server\server_hl2mp-2005.vcproj</code> and replace '''2005''' with '''2008'''.}}
{{Note|If you are using the Orange box source code, you will need to copy <code>Game_HL2MP-2005.sln</code>, <code>game\client\client_hl2mp-2005.vcproj</code> and <code>game\server\server_hl2mp-2005.vcproj</code> and replace '''2005''' with '''2008'''.}}
Line 23: Line 15:
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.
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.


== Modifying files ==
== Modifying Files ==
With that done, we can now go ahead and modify our setup.
With that done, we can now go ahead and modify our setup.


Line 30: Line 22:
{{Note|If you are using the Orange Box version of the source code, the paths will be different, but you can still simply change the 2005 to 2008.}}
{{Note|If you are using the Orange Box version of the source code, the paths will be different, but you can still simply change the 2005 to 2008.}}


== Upgrading the Project ==
* Open <code>Game_HL2MP-2008.sln</code> in Visual Studio 2008. You will be prompted to upgrade the project files.
* Open <code>Game_HL2MP-2008.sln</code> 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.
* At the first section of the upgrade process, you are asked if you want to create a backup before converting.
Line 36: Line 29:
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.
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.


== Setting up Microsoft SDK's==
== Installing the DirectX SDK ==
You will now need to install the DirectX SDK and then follow the instructions below to include them in the build process
For creating new shaders you will need to download and install the [http://msdn.microsoft.com/directx/sdk/ MS DirectX SDK (March 2008)]. Once you've done that  follow the instructions below to include them in the build process.
 
=== Files ===
*[http://msdn.microsoft.com/directx/sdk/ MS DirectX SDK (March 2008)]
 
 
Go to Tools - Options: Projects and Solutions - VC++ Directories
 
* Then select "Include files" and add "...\Microsoft DirectX SDK (March 2008)\Include"
 
* Then select "Library files" and add "...\Microsoft DirectX SDK (March 2008)\Lib\x86"
 
Finally, in the Solution Explorer right click 'client_hl2', and select Properties, then:


* In the client_hl2 properties window, navigate to Linker -> Input
* In VS2008 Go to Tools - Options: Projects and Solutions - VC++ Directories
* Select the 'Additional Properties' row. Then click the '...' on the right hand side of the row
* 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.
* 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'
* Repeat these steps for 'server_hl2'


== Important changes ==
== Other Important Changes ==
 
We need to make sure we're compiling in Release (VS2008, in fact does not compile debug mode).
We need to make sure we're compiling in Release (VS2008, in fact does not compile debug mode)


* Right-click on "Solution Game_HL2MP-2008" in your Solution Explorer and select Properties.
* Right-click on "Solution Game_HL2MP-2008" in your Solution Explorer and select Properties.
* Click the Configuration Properties option.
* Click the Configuration Properties option.
* Under the Configuration tab in the table that appears on the right of the window, use the selection box to change or verify that both solutions are set to "Release". Once you've done this, press Apply, then OK.
* Under the Configuration tab in the table that appears on the right of the window, use the selection box to change or verify that both solutions are set to "Release". Once you've done this, press Apply, then OK.
The compiler also encounters this bug: http://developer.valvesoftware.com/cgi-bin/bugzilla/show_bug.cgi?id=214. In order to fix it you just need to change some lines:
* Open <code>c_vguiscreen.cpp</code> and find this line
dist = c_x / tan( M_PI * scaled_fov / 360.0 );
* Now replace that line with these:
float dist_denom = tan( M_PI * scaled_fov / 360.0f );
dist = c_x / dist_denom;


You might think we're all done, but if you compiled right now, you'd find that you still get errors and whole lot of warnings. The warnings are just fine, but those stupid errors are the only thing preventing you from compiling correctly. Luckily, there's an easy fix; just compile the 'client_hl2mp' first, then the 'server_hl2mp' - it's that simple!
You might think we're all done, but if you compiled right now, you'd find that you still get errors and whole lot of warnings. The warnings are just fine, but those stupid errors are the only thing preventing you from compiling correctly. Luckily, there's an easy fix; just compile the 'client_hl2mp' first, then the 'server_hl2mp' - it's that simple!

Revision as of 08:32, 2 May 2008

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.

Backing Up Files

To do all of this in a non-destructive way, we must copy our VS2005 files and make a new solution. If you have just created your mod, you can skip this step.

  • Copy src/Game_HL2MP-2005.sln and rename the copy to Game_HL2MP-2008.sln.
  • Copy src/cl_dll/client_hl2mp-2005.vcproj and rename the copy to client_hl2mp-2008.vcproj.
  • Copy src/dlls/server_hl2mp-2005.vcproj and rename the copy to server_hl2mp-2008.vcproj.
Note.pngNote:If you are using the Orange box source code, you will need to copy 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.

Modifying Files

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 and dlls\server_hl2mp-2005.vcproj. Change the 2005 in both of them to 2008.
Note.pngNote:If you are using the Orange Box version of the source code, the paths will be different, but you can still simply change the 2005 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 to download and install the MS DirectX SDK (March 2008). Once you've done that follow the instructions below to include them in the build process.

  • 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

We need to make sure we're compiling in Release (VS2008, in fact does not compile debug mode).

  • Right-click on "Solution Game_HL2MP-2008" in your Solution Explorer and select Properties.
  • Click the Configuration Properties option.
  • Under the Configuration tab in the table that appears on the right of the window, use the selection box to change or verify that both solutions are set to "Release". Once you've done this, press Apply, then OK.

You might think we're all done, but if you compiled right now, you'd find that you still get errors and whole lot of warnings. The warnings are just fine, but those stupid errors are the only thing preventing you from compiling correctly. Luckily, there's an easy fix; just compile the 'client_hl2mp' first, then the 'server_hl2mp' - it's that simple!

Your SDK installation should now be fully operational. You might still get some warnings, but you shouldn't get any more errors on your first build if you followed these steps. I recommend you build now while the installation is still fresh so you don't have to do this again and so you know everything is working the way it should. If you are still getting errors, keep retrying this tutorial until you don't anymore, as I've confirmed this works.