Compiling under VS2010: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with '== Compiling with Visual Studio C++ 2010 == Visual Studio 2010 has a lot of great features, unfortunately there's not a lot of support for it yet (it is in beta after all). It t…')
 
Line 52: Line 52:
== Running Your Mod ==
== Running Your Mod ==


At this point you can continue to the steps from [http://developer.valvesoftware.com/wiki/Installing_and_Debugging_the_Source_Code#Debugging here].
At this point you can continue from [http://developer.valvesoftware.com/wiki/Launching_from_Visual_Studio here] then launch your mod through Visual Studio.


[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Programming]]
[[Category:Programming]]
[[Category:Source SDK FAQ]]
[[Category:Source SDK FAQ]]

Revision as of 05:11, 14 March 2010

Compiling with Visual Studio C++ 2010

Visual Studio 2010 has a lot of great features, unfortunately there's not a lot of support for it yet (it is in beta after all). It takes a fair amount of tweaking to get it working, and your debug DLLs compiled from Visual Studio 2010 will not work - you MUST use release DLLs.

Opening Your Mod

Once you've created your mod, open up Visual Studio and go to File -> Open -> Project\Solution. Navigate to your mod's source directory and open up Game_Episodic-2005.sln. It will ask if you want to convert it, do so. If it's a new mod don't bother choosing the back it up option.

Fixing Compilation

As mentioned above, YOU CANNOT USE DEBUG DLLS with Visual Studio 2010. They will compile but the game will refuse to load them. This means you'll be doing all your work in Release configuration. Up near the top of your Visual Studio window you'll see a drop down box saying Debug, change that to Release. Now to get your solution to compile you'll have to go through a few steps.

  1. Follow the Fix Debug Compilation step from this tutorial.
  2. Right click on Client_Episodic and go to Properties. Go to Configuration Properties->General and change Target Name to client.
  3. Right click on Server_Episodic and go to Properties. Go to Configuration Properties->General and change Target Name to server.
  4. Right click on Client_Episodic and go to Properties. Go to Custom Build Step. If you click on Command Line a drop down arrow will appear. Click that and go to <Edit...>. Make the appropriate changes to the following code based on your mod location/name and insert them here:

if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.dll" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.dll"
if exist "$(TargetDir)client.dll" copy "$(TargetDir)client.dll" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"
if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb"
if exist "$(TargetDir)client.pdb" copy "$(TargetDir)client.pdb" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"

  1. Right click on Server_Episodic and go to Properties. Go to Custom Build Step. If you click on Command Line a drop down arrow will appear. Click that and go to <Edit...>. Make the appropriate changes to the following code based on your mod location/name and insert them here:

if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\server.dll" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\server.dll"
if exist "$(TargetDir)server.dll" copy "$(TargetDir)client.dll" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"
if exist "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb" attrib -r "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin\client.pdb"
if exist "$(TargetDir)client.pdb" copy "$(TargetDir)client.pdb" "c:\program files (x86)\steam\steamapps\SourceMods\<MODNAME>\bin"

There are times when Visual Studio won't copy your DLLs and PDBs over to the ...\SourceMods\<MODNAME>\bin\ directory even after it's compiled changes in your code. If this happens just delete the contents of ...\SourceMods\<MODNAME>\bin\ and rebuild your solution, or just move them yourself. Either way works.


Fixing Warnings

You're going to be stuck with at least one warning during compilation, but you can get rid of some of them. Open the following files in your Client_Episodic project (Source Files -> HL2 DLL) and move #include "cbase.h" up to the top of the includes:

  1. hud_locator.cpp
  2. hud_credits.cpp
  3. hud_flashlight.cpp

Next highlight both Client_Episodic and Server_Episodic from the main window, right click and go to Properties. Go to Configuration Properties->General and ensure that your configuration is set to release in the drop down window at the top. Change .\Release\ to Release\ (remove the .\) Click OK.


Running Your Mod

At this point you can continue from here then launch your mod through Visual Studio.