Compiling under VS2005: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(updated to reflect new SLNs)
Line 5: Line 5:
== Installing ==
== Installing ==


The Visual Studio Express 2005 line is no longer available for download from Microsoft. If you require Visual Studio 2005 and are eligible, you can download it from [http://www.dreamspark.com Dreamspark], otherwise you should use Visual Studio 2008.
''Visual C++ Express 2005 is no longer available from Microsoft. Visual Studio 2005 can downloaded from Microsoft's [http://www.dreamspark.com Dreamspark] website if you are eligible; otherwise you should use Visual Studio 2008.''


After Visual Studio or Visual C++ Express has been installed, run Windows Update to patch it. Do this twice if you are using Windows Vista to catch a compatibility update.
After Visual Studio or Visual C++ Express has been installed, run Windows Update to patch it. Do this twice if you are using Windows Vista to catch a compatibility update.
Line 19: Line 19:
{{note|If you are installing on a 64bit OS, remember that it is still the 32bit (x86) libraries that you want. They aren't selected by default.}}
{{note|If you are installing on a 64bit OS, remember that it is still the 32bit (x86) libraries that you want. They aren't selected by default.}}


Once you have the Windows SDK installed, you need to tell Visual C++ where the SDK is located. To do this, navigate to ''Tools > Options > Projects and Solutions > VC++ Directories''. Add the Windows SDK's <code>\bin</code> folder to the list. The default location is:
Once you have the Windows SDK installed, you need to tell Visual C++ where the SDK is located. To do this, navigate to ''Tools > Options > Projects and Solutions > VC++ Directories''. Add the Windows SDK's <code>\bin</code> folder to the list. The default location is <code>C:\Program Files\Microsoft SDKs\Windows\v6.1\bin</code>.


C:\Program Files\Microsoft SDKs\Windows\v6.1\bin
Click on the drop-down list that ''currently'' says "Executable files". You need to add the <code>\include</code> folder to the 'Includes' list and the <code>\lib</code> folder to the 'Library' list.


Click on the drop-down list that currently says "Executable files". You now need to add the <code>\include</code> folder to the 'Includes' list and the <code>\lib</code> folder to the 'Library' list.
[[Image:Vc2005 dirs.png|center|Adding the Windows SDK's includes.]]


{{tip|You'll need to go through a similar process if you've installed the DirectX SDK.}}
{{tip|You'll need to go through a similar process if you've installed the DirectX SDK.}}


[[Image:Vc2005 dirs.png|center|Adding the Windows SDK's includes.]]
== LNK2019 errors ==


Hit OK to return to the workspace. Now right-click on on the server project and choose Properties. Navigate to ''Configuration Properties > Linker > Input'' and add <code>user32.lib</code> to the first setting. It should now read <code>winmm.lib user32.lib</code>. Repeat this in Release mode (choose it from the top-left drop-down list), then repeat both modes again for the client project.
Right-click on the client and server projects in turn and select the last option in the menu, Properties. Then navigate to ''Configuration properties > Linker > Input'' and make the first item, "Additional Dependencies", read <code>winmm.lib user32.lib</code>. Make sure you've done this for both Debug and Release mode (switch between them in the top left of the Properties window).


If you get "unresolved external" errors, try adding <code>kernel32.lib</code> as well.
If still get "unresolved external" errors, try adding <code>kernel32.lib</code> as well.


== intrin.h errors ==
== intrin.h errors ==


This is a bug with VC++2005 that you may encounter. To fix it, open <code>C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h</code> and comment out lines 944 and 945. This fixes a contradiction between two VC++ header files and shouldn't cause any damage.
This is a bug with VC++2005 that you may encounter. To fix it, open <code>C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h</code> and comment out lines 944 and 945. This fixes a contradiction between two VC++ header files and shouldn't cause any damage.
== Fixing the custom build step ==
:''This problem is fixed in the current [[SDK Beta]].''
The project files created by the mod wizard won't put your compiled DLLs in the right folders.
Open the client properties and navigate to ''Configuration Properties -> Custom Build Step -> General''. Click the '...' button on the right of Command Line and replace everything there with this:
if exist "c:\program files\steam\steamapps\SourceMods\MyMod\bin\client.dll";attrib -r "c:\program files\steam\steamapps\SourceMods\MyMod\bin\client.dll"
copy "$(TargetDir)"client.dll "c:\program files\steam\steamapps\SourceMods\MyMod\bin"
if exist "c:\program files\steam\steamapps\SourceMods\MyMod\bin\client.pdb";attrib -r "c:\program files\steam\steamapps\SourceMods\MyMod\bin\client.pdb"
copy "$(TargetDir)"client.pdb "c:\program files\steam\steamapps\SourceMods\MyMod\bin"
Then in Output, paste:
c:\program files\steam\steamapps\SourceMods\MyMod\bin\client.dll;c:\program files\steam\steamapps\SourceMods\MyMod\bin\client.pdb
Remember to replace <code>MyMod</code> with the actual name of your mod.
Now open the server properties and navigate to ''Configuration Properties -> Custom Build Step -> General''. Click the '...' button on the right of Command Line and replace everything there with this:
if exist "c:\program files\steam\steamapps\SourceMods\MyMod\bin\server.dll";attrib -r "c:\program files\steam\steamapps\SourceMods\MyMod\bin\server.dll"
copy "$(TargetDir)"server.dll "c:\program files\steam\steamapps\SourceMods\MyMod\bin"
if exist "c:\program files\steam\steamapps\SourceMods\MyMod\bin\server.pdb";attrib -r "c:\program files\steam\steamapps\SourceMods\MyMod\bin\server.pdb"
copy "$(TargetDir)"server.pdb "c:\program files\steam\steamapps\SourceMods\MyMod\bin"
Then in Output, paste:
c:\program files\steam\steamapps\SourceMods\MyMod\bin\server.dll;c:\program files\steam\steamapps\SourceMods\MyMod\bin\server.pdb
Remember to replace <code>MyMod</code> with the actual name of your mod.


== Running your mod ==
== Running your mod ==

Revision as of 11:05, 16 June 2009

Visual Studio 2005 is the officially-supported IDE of the Source SDK, and if all is well you won't need to do anything special to use it. If you're using Visual C++ 2005 Express or if something is awry however, this page should get you up and running. It assumes you are compiling the Orange Box source code.

Installing

Visual C++ Express 2005 is no longer available from Microsoft. Visual Studio 2005 can downloaded from Microsoft's Dreamspark website if you are eligible; otherwise you should use Visual Studio 2008.

After Visual Studio or Visual C++ Express has been installed, run Windows Update to patch it. Do this twice if you are using Windows Vista to catch a compatibility update.

Windows SDK

If you're using Visual C++ Express 2005 you need to install the Windows SDK. (If you're using Visual Studio 2005 this has already been done for you.)

It doesn't matter which version you download; this one does the job well enough. Don't worry that it talks about Vista - it also covers XP. Windows 2000 users however need to download the older Platform SDK instead.

Note.pngNote:You only need the "headers and libraries" component, about half-way through the list that the installer will present. They're about a 20MB download...the complete SDK is over 2GB!
Note.pngNote:If you are installing on a 64bit OS, remember that it is still the 32bit (x86) libraries that you want. They aren't selected by default.

Once you have the Windows SDK installed, you need to tell Visual C++ where the SDK is located. To do this, navigate to Tools > Options > Projects and Solutions > VC++ Directories. Add the Windows SDK's \bin folder to the list. The default location is C:\Program Files\Microsoft SDKs\Windows\v6.1\bin.

Click on the drop-down list that currently says "Executable files". You need to add the \include folder to the 'Includes' list and the \lib folder to the 'Library' list.

Adding the Windows SDK's includes.
Tip.pngTip:You'll need to go through a similar process if you've installed the DirectX SDK.

LNK2019 errors

Right-click on the client and server projects in turn and select the last option in the menu, Properties. Then navigate to Configuration properties > Linker > Input and make the first item, "Additional Dependencies", read winmm.lib user32.lib. Make sure you've done this for both Debug and Release mode (switch between them in the top left of the Properties window).

If still get "unresolved external" errors, try adding kernel32.lib as well.

intrin.h errors

This is a bug with VC++2005 that you may encounter. To fix it, open C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h and comment out lines 944 and 945. This fixes a contradiction between two VC++ header files and shouldn't cause any damage.

Running your mod

Remember to run with -allowdebug if you've got debug builds!

See also

Template:Otherlang:en Template:Otherlang:en:de