Compiling under VS2005

From Valve Developer Community
Jump to: navigation, search
English (en)Deutsch (de)русский (ru)中文 (zh)
... Icon-Important.png

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, you'll need to do some work to get it up and running. This page assumes you are compiling the latest Orange Box source code.

Installing

Is it recommended to obtain the full Visual Studio 2005 Professional since it includes the Windows/Platform SDK. VCE2005 is no longer supported by or officially available from Microsoft. It can still be downloaded from Microsoft Through it might disappear sometime soon!

After Visual Studio or VCE has been installed, it is recommended to install SP1 (Be warned that it has a install bug of consuming a lot of space!)and Vista Update for SP1. Then run Windows Update to finish patching it. (If there are no updates for VS/VCE, don't worry)

Windows SDK (Express Only)

If you're using Visual C++ Express 2005 you need to install the Windows SDK.


Be warned that the Windows 7 SDK offered below is known to cause issues with Visual Studio 2010 SP1.

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 should follow instructions in Older SDK

*: I'm pretty sure it does matter which version you download. See below. -- Neverender 17:26, 6 October 2012 (PDT)
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.

Open the Solution

  1. Launch your copy of Microsoft Visual Studio.
  2. Select File->Open->Project/Solution from the menu and open the Game_Episodic-2005.sln solution located in your mod's src directory, select the one that matches your version of Microsoft Visual Studio. If you selected mod from scratch, "Scratch" will appear there instead.

LNK2019 Errors

If you receive these 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 you get "unresolved external" errors, try adding kernel32.lib as well.

error C2733 referring to winnt.h or intrin.h

You may receive an error such as: "error C2733: second C linkage of overloaded function '_interlockedbittestandreset' not allowed"

This error is caused by trying to build against an incompatible version of the Windows SDK/Platform SDK. When using the full version of Visual C++ 2005, your Visual C++ directories (in "Options") should not refer to any newer external SDK include/lib paths; only the ones included with the Visual C++ 2005 installation by default. Reverting the "VC++ Directories" settings to default should solve this problem.

For Express users ONLY, since you have no choice but to install an external SDK, this version may help. If all else fails, some users have resorted to working around this problem by editing their SDK headers.

Warning.pngWarning:Editing vendor provided header files is a BAD idea. This is a hack of last resort; however, by using Visual C++ Express, you are already working in an unsupported configuration.

Here are the previous instructions given:

"Open C:\Program Files\Microsoft Visual Studio 8\VC\include\intrin.h and comment out lines 944 and 945. If you continue to receive errors, comment out the referenced lines (typically 913 and 912) and recompile."

You put the same download before in Windows SDK Express Only. : MatiasKiller21 [1] : July 01 2015.

Running Your Mod

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

See also