Installing and Debugging the Source Code: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(come back + previous detailed informations removed here http://developer.valvesoftware.com/w/index.php?title=Installing_and_Debugging_the_Source_Code&diff=77553&oldid=77503)
Line 1: Line 1:
[[Category:Programming]][[Category:Modding]]
This article will explain the basic steps for installing and debugging the source code.


=Overview=
== Step By Step ==


The general steps to installing and debugging the source code are:
=== Run the Create a Mod wizard ===


# Run the '''[[Create a Mod]]''' tool in the SDK to install the source code.
# Run the Source SDK from Steam and choose the '''Create a Mod''' link.
# Use Microsoft Visual Studio .NET 2003 to compile the source code.
# You can normally choose any type of mod here, but for the purposes of this tutorial, choose the '''Modify Half-Life 2 Single Player''' option and click '''Next'''.
# Setup debugging parameters.
# In the top edit control of the next dialog, enter a directory where you would like to create a mod. This tutorial will assume you entered '''C:\MyMod'''.
# Run in the debugger.
# In the bottom edit control, enter any name for your mod. This will become a subdirectory under your '''''SteamInstallPath'''\SteamApps\SourceMods'' folder. This example will assume you entered '''MyMod''' here.
# Click the '''Next''' button and the source code will be installed on your hard drive.
# Wait for the mod wizard to finish.


=Step By Step=
=== Compile the Source Code ===
For general considerations about compilation go here : [[Compiler Choices]]


===Run the Create a Mod wizard===
For more specific :
* [[Compiling under VS2003]]
* [[Compiling under VS2005]]
* [[Compiling under VS2008]]


* Run the Source SDK from Steam and choose the '''[[Create a Mod]]''' link.
{{note|It is on debug compile by default. In order to run the mod with a debug dll you must right click the mod in the Steam game browser, click '''Properties''' then '''Set Launch Options...''' and add ''-allowdebug'' to the end of anything that may already be there (separated by spaces). You can change to a release build (for distributing the mod) in the configuration manager.}}
* You can normally choose any type of mod here, but for the purposes of this tutorial, choose the '''Modify Half-Life 2 Single Player''' option and click '''Next'''.
* In the top edit control of the next dialog, enter a directory where you would like to create a mod. This tutorial will assume you entered '''C:\MyMod'''.
* In the bottom edit control, enter any name for your mod. This will become a subdirectory under your '''''SteamInstallPath'''\SteamApps\SourceMods'' folder. This example will assume you entered '''MyMod''' here.
* Click the '''Next''' button and the source code will be installed on your hard drive.
* Wait for the mod wizard to finish.
 
===Compile the Source Code===
 
[[Compiling under VS2003]]<br>
[[Compiling under VS2005]]<br>
[[Compiling under VS2008]]<br>


{{note|It is on debug compile by default. In order to run the mod with a debug dll you must right click the mod in the Steam game browser, click '''Properties''' then '''Set Launch Options...''' and add ''-allowdebug'' to the end of anything that may already be there (separated by spaces). You can change to a release build (for distributing the mod) in the configuration manager.}}
Currently the code is better compiling on VS2005. You can download it at http://www.microsoft.com/express/2005/


VCE2005 users need to download the [http://www.microsoft.com/downloads/details.aspx?FamilyID=e6e1c3df-a74f-4207-8586-711ebe331cdc&DisplayLang=en Windows SDK] (Windows 2000 users: [http://www.microsoft.com/downloads/details.aspx?familyid=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en Platform SDK]). Visual Studio and VCE2008 users do not.


===Debugging===
===Debugging===
Line 35: Line 31:
   
   
{{note|This will only work if you have installed and launched the Source SDK Base.}}  
{{note|This will only work if you have installed and launched the Source SDK Base.}}  
* In the '''Solution Explorer window,''' right-click on the current project (the one in bold) and choose '''Properties'''.  
# In the '''Solution Explorer window,''' right-click on the current project (the one in bold) and choose '''Properties'''.  
* In the Property Pages dialog that appears, choose the Debugging item on the left-hand side.  
# In the Property Pages dialog that appears, choose the Debugging item on the left-hand side.  
* On the right-hand side, in the text control next to '''Command''', enter <code>C:\Steam\SteamApps\'''Username'''\source sdk base\hl2.exe</code> (adjusting the folder names given here to reflect your own Steam installation).  
# On the right-hand side, in the text control next to '''Command''', enter <code>C:\Steam\SteamApps\'''Username'''\source sdk base\hl2.exe</code> (adjusting the folder names given here to reflect your own Steam installation).  
* Next to '''Command Arguments''', enter <code>-dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod"</code> (where '''MyMod''' is the name of your mod you entered in the ''Create a Mod'' dialog).  
# Next to '''Command Arguments''', enter <code>-dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod"</code> (where '''MyMod''' is the name of your mod you entered in the ''Create a Mod'' dialog).  
* Next to '''Working Directory''', enter <code>C:\Steam\SteamApps\'''Username'''\source sdk base</code> (adjusting the folder names given here to reflect your own Steam installation).  
# Next to '''Working Directory''', enter <code>C:\Steam\SteamApps\'''Username'''\source sdk base</code> (adjusting the folder names given here to reflect your own Steam installation).  
* Click the '''OK''' button.  
# Click the '''OK''' button.  
 


==== Run in the debugger ====  
==== Run in the debugger ====  
 
 
* ''Important: after an SDK update, you must make sure to run whatever game you're editing'' '''through Steam''' ''once (only one time is necessary) before running in the debugger. If you don't, you may get Steam errors when running through the debugger.''  
# ''Important: after an SDK update, you must make sure to run whatever game you're editing'' '''through Steam''' ''once (only one time is necessary) before running in the debugger. If you don't, you may get Steam errors when running through the debugger.''  
* Right-click on the same project you were editing the properties for, and choose Debug->Start New Instance.  
# Right-click on the same project you were editing the properties for, and choose Debug->Start New Instance.  
* If you get a warning that <code>hl2.exe</code> has no debugging information, ignore it.  
# If you get a warning that <code>hl2.exe</code> has no debugging information, ignore it.  
* It should now launch Half-Life 2 and run your code. You can make modifications to the code now, rebuild, and rerun the game with your changes!
# It should now launch Half-Life 2 and run your code. You can make modifications to the code now, rebuild, and rerun the game with your changes!
 
==== Alternative : run-time attachment ====


# Start the mod using Steam
# Inside Visual Studio, Main Menu > Debug > Attach to Process...
# Select the hl2.exe process with the title of your mod
{{tip|you can start the app in windowed mode for better comfort : add a "-window" option in your run_mod.bat}}


=Links=
== Links ==


A good next step after mastering this document is to look at the [[Your First Entity]] document, in which you will make changes to some of the source code.
A good next step after mastering this document is to look at the [[Your First Entity]] document, in which you will make changes to some of the source code.


If you plan to integrate code updates from Valve, and if you want code backups and revision history, take a look at the [[Using Source Control with the Source SDK]] document.
If you plan to integrate code updates from Valve, and if you want code backups and revision history, take a look at the [[Using Source Control with the Source SDK]] document.
{{otherlang:en}} {{otherlang:en:jp|Installing and Debugging the Source Code:jp}}
 
{{otherlang:en}}  
{{otherlang:en:jp|Installing and Debugging the Source Code:jp}}
 
[[Category:Programming]]
[[Category:Modding]]

Revision as of 20:22, 3 June 2008

This article will explain the basic steps for installing and debugging the source code.

Step By Step

Run the Create a Mod wizard

  1. Run the Source SDK from Steam and choose the Create a Mod link.
  2. You can normally choose any type of mod here, but for the purposes of this tutorial, choose the Modify Half-Life 2 Single Player option and click Next.
  3. In the top edit control of the next dialog, enter a directory where you would like to create a mod. This tutorial will assume you entered C:\MyMod.
  4. In the bottom edit control, enter any name for your mod. This will become a subdirectory under your SteamInstallPath\SteamApps\SourceMods folder. This example will assume you entered MyMod here.
  5. Click the Next button and the source code will be installed on your hard drive.
  6. Wait for the mod wizard to finish.

Compile the Source Code

For general considerations about compilation go here : Compiler Choices

For more specific :

Note.pngNote:It is on debug compile by default. In order to run the mod with a debug dll you must right click the mod in the Steam game browser, click Properties then Set Launch Options... and add -allowdebug to the end of anything that may already be there (separated by spaces). You can change to a release build (for distributing the mod) in the configuration manager.

Currently the code is better compiling on VS2005. You can download it at http://www.microsoft.com/express/2005/

VCE2005 users need to download the Windows SDK (Windows 2000 users: Platform SDK). Visual Studio and VCE2008 users do not.

Debugging

Setup debugging parameters

Note.pngNote:This will only work if you have installed and launched the Source SDK Base.
  1. In the Solution Explorer window, right-click on the current project (the one in bold) and choose Properties.
  2. In the Property Pages dialog that appears, choose the Debugging item on the left-hand side.
  3. On the right-hand side, in the text control next to Command, enter C:\Steam\SteamApps\Username\source sdk base\hl2.exe (adjusting the folder names given here to reflect your own Steam installation).
  4. Next to Command Arguments, enter -dev -sw -game "C:\Steam\SteamApps\SourceMods\MyMod" (where MyMod is the name of your mod you entered in the Create a Mod dialog).
  5. Next to Working Directory, enter C:\Steam\SteamApps\Username\source sdk base (adjusting the folder names given here to reflect your own Steam installation).
  6. Click the OK button.

Run in the debugger

  1. Important: after an SDK update, you must make sure to run whatever game you're editing through Steam once (only one time is necessary) before running in the debugger. If you don't, you may get Steam errors when running through the debugger.
  2. Right-click on the same project you were editing the properties for, and choose Debug->Start New Instance.
  3. If you get a warning that hl2.exe has no debugging information, ignore it.
  4. It should now launch Half-Life 2 and run your code. You can make modifications to the code now, rebuild, and rerun the game with your changes!

Alternative : run-time attachment

  1. Start the mod using Steam
  2. Inside Visual Studio, Main Menu > Debug > Attach to Process...
  3. Select the hl2.exe process with the title of your mod
Tip.pngTip:you can start the app in windowed mode for better comfort : add a "-window" option in your run_mod.bat

Links

A good next step after mastering this document is to look at the Your First Entity document, in which you will make changes to some of the source code.

If you plan to integrate code updates from Valve, and if you want code backups and revision history, take a look at the Using Source Control with the Source SDK document.

Template:Otherlang:en Template:Otherlang:en:jp