Welcome, Guest! Login | Register

Building the Half-Life DLLs [Print this Article]
Posted by: Entropy
Date posted: May 04 2003
User Rating: 3.7 out of 5.0
Number of views: 16937
Number of comments: 9
Description: with the Microsoft Command-Line Compiler
Building the Half-Life DLLs with the Microsoft Command-Line Compiler

This tutorial is intended to get you started building the Half-Life dlls using the Microsoft command line compiler, available free from Microsoft's website. This compiler is identical to the one included in Micrsoft Visual C++ .NET Standard. It will allow you to build the SDK without modification, including the VGUI code. In order to install and use the compiler, you need Windows 2000 or Windows XP and a minimum of 600-700MB hard disk space available.

Step 1: Download and install the compiler and build environment

A. Download and install the .NET redistributable package. After installing, you can delete dotnetfx.exe.
B. Download and install the .NET framework SDK. If you're short on disk space (or just don't want them), you don't need to install the Samples. Once it's installed, you can delete setup.exe. You can also delete the 'Microsoft .NET SDK' directory (by default C:\Program Files\Microsoft .NET SDK) if you're short on disk space.
C. Install the Windows Core and Data Access SDK's. Go to SDK Update, then click Downloads->Install to get to the catalog (don't click on any of the SDK's at the left unless you want that entire SDK, which can be quite large). Once on the catalog page, select 'Build environment' under both Core SDK and Microsoft Data Access Components, then click 'Start Installation'.

Step 2: Setting environment variables

Next, you'll need to set up the environment variables needed by the compiler. Go to the Control Panel and open the System icon. Select the 'Advanced' tab, then the 'Environment Variables' button. Under User Variables, find 'PATH', select it and press the 'Edit' button (if PATH is not present, press the 'New' button). In the variable value box, enter the following: C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin;C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE (these examples assume you installed everything to the default path. If not, replace these paths with the paths you installed to). If the PATH variable already has a value, just add a semicolon to the end and then type the above text. The PATH variable is a list of directories Windows will look in for any commands you enter that it can't find in the current directory. Add a variable named 'INCLUDE' with a value of C:\Program Files\Microsoft SDK\include;c:\Program Files\Microsoft Visual Studio .NET 2003\VC7\include and a variable named 'LIB' with a value of C:\Program Files\Microsoft SDK\lib;c:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib. INCLUDE and LIB are used by the compiler and linker to find (you guessed it!) standard include files and any libraries you use.

Step 3: The Half-Life SDK

Download and install the Half-Life SDK of your choice. After installing, create a folder to hold your mod's source code (for the rest of this tutorial I'll assume you've created a folder named C:\Projects\MyMod). Keep the folder names short to save yourself typing and don't put any spaces in them or make (to be discussed later) may not work properly. Copy all the folders in the "\SDK\Single Player Source" folder to your newly created mod source directory. You should have something like this:
user posted image

Step 4: GNU Make

Make is a program that will determine which files in your project have changed since your last build, then rebuild only those files which need to be brought up to date. I've compiled a binary of GNU Make for Windows. Download this file and double click it to extract make (by default, it will be installed in c:\make). You'll need to add the location to which you installed make to your PATH. The source for GNU make is available from the Free Software Foundation. The GNU Make Manual is also available online.

Step 5: Building the DLLs

Before compiling, two small changes need to be made to the source. First, in dlls\weapons.h, line 448 needs to be changed from:
 CODE  
HasWeapon( CBasePlayerItem *pCheckItem );

to:
 CODE  
BOOL HasWeapon( CBasePlayerItem *pCheckItem );

Second, line 1079 in cl_dll\hud_spectator.cpp needs to be changed from:
 CODE  
i = sqrt(i);

to:
 CODE  
i = sqrt((float)i);

Now you just need some instructions for make to do its job. I've written makefiles which will build both dlls for you and put them in a self-extracting zip. You should extract these files to the top-level source directory for your mod (in our example, c:\projects\mymod). This will create the files c:\projects\mymod\Makefile, c:\projects\mymod\dlls\ServerMakefile, and c:\projects\mymod\cl_dll\ClientMakefile. Once that's done, open a command prompt window and change to the top level of your mod source directory (in our example, c:\projects\mymod) and type make. Now sit back and watch while the DLLs are built! (On builds after the first one, you will see a message like: [createdir] Error 1 (Ignored). This is normal.) If the build is successful, you will see a message indicating success at the end. Make sure you can build the unmodified SDK before trying to build your mod! By default, the makefiles will build debug versions of both the server and client dlls and place them in dlls\debug\ and cl_dlls\debug\, respectively. Typing make alone is the same as typing make debug. You can also build a release version of both dlls by typing make release. To delete all the intermediate and output files, type make clean. If you would like to see each command as it is executed, put a '#' at the beginning of the .SILENT line in Makefile. (In makefiles, lines beginning with a # are comments).

If you want to make life even easier, you can change the /OUT: directive in the LINK_OPTIONS of dlls\ServerMakefile and cl_dll\ClientMakefile to put the output files in your mod's dlls and cl_dlls folders, respectively, and every time you build, the dlls will be in place to be used. For example, if Half-Life is installed to C:\Half-Life, and your mod directory is named mymod, you should replace /OUT:hl.dll in the ServerMakefile with /OUT:C:\Half-Life\mymod\dlls\hl.dll and replace /OUT:client.dll in the ClientMakefile with /OUT:C:\Half-Life\mymod\cl_dlls\client.dll.

Congratulations! You're now ready to build your mod!

Please let me know of any errors in this article or bugs in the makefiles by email or by a private message on the forums. If you have an improvement for the makefiles, I'd also like to know about that.

Rate This Article
This article is currently rated: 3.7 out of 5.0 (3 Votes)

You have to register to rate this article.
User Comments Showing comments 1-9

Posted By: BulliT on May 08 2004 at 10:02:33
Microsoft released a package that is a bit easier to download/install.
http://msdn.microsoft.com/visualc/vctoolkit2003/

Posted By: [ICR] on May 25 2004 at 15:49:23
I have modified the makefile to work with the Multiplayer only source.
Download http://seascape.uk.net/cubulargames/ICR_Du...verMakefile.zip
Only the server changes so I have only included the server makefile. Before you can make the file, you must copy the hl.def, hl.dsp and hlgl.def files from the Single Player source, as they do not appear to be included in the Multiplayer source.

Also worthy to note, if you stop a compile half-way through, it's usefull to use make clean before you compile next time to avoid errors.

Posted By: Unknown on Aug 16 2004 at 19:10:02
i`m sorry i don`t understand some of it!

Posted By: NoBody on Sep 06 2004 at 00:54:50
i am just precented with a "aflock.obj missing"

Posted By: Unknown on Dec 04 2004 at 01:44:30
Whoops, I thought this was dealing with HL2. No wonder. Haha.Edited by Unknown on Dec 04 2004, 06:01:26

Posted By: Entropy on Dec 04 2004 at 03:31:42
That means you're missing the file 'aflock.cpp', I believe. I haven't worked on HL in a while - are you using the full SDK? The multiplayer SDK (which I think they stopped distributing) wouldn't have aflock.cpp (and a number of others) in it. Use the full SDK. Alternatively, for any .cpp file you don't have, you can remove the references to the corresponding .obj file from the makefile. You'd need to remove the *.obj reference in the SERVER_OBJECTS or PM_SHARED_OBJECTS areas as well as the entire line starting with the *.obj reference later in the file. In other words, to remove aflock.cpp, you would remove aflock.obj from this line:

SERVER_OBJECTS = aflock.obj agrunt.obj airtank.obj animating.obj \

and this entire line:

aflock.obj : aflock.cpp extdll.h util.h cbase.h monsters.h squadmonster.h

Hope that helps.

Posted By: Unknown on Dec 04 2004 at 16:17:13
Now I get the following, when trying to compile for the *correct* game this time (HL1 :P)

============
C:\SIERRA\Half-Life\SDK\sp>make
make[1]: Entering directory `C:/SIERRA/Half-Life/SDK/sp/dlls'
aflock.cpp
c:\SIERRA\Half-Life\SDK\sp\dlls\extdll.h(42) : fatal error C1083: Cannot open in
clude file: 'windows.h': No such file or directory
make[1]: *** [aflock.obj] Error 2
make[1]: Leaving directory `C:/SIERRA/Half-Life/SDK/sp/dlls'
make: *** [server_dbg] Error 2

Posted By: gedis on Feb 19 2005 at 12:17:34
The link to makefiles doesn't work...

Posted By: Hp-P00nst3r on Apr 03 2005 at 02:55:05
yea it doesnt work.


You must register to post a comment. If you have already registered, you must login.

Latest Articles
3rd person View in Multiplayer
Half-Life 2 | Coding | Client Side Tutorials
How to enable it in HL2DM

By: cct | Nov 13 2006

Making a Camera
Half-Life 2 | Level Design
This camera is good for when you join a map, it gives you a view of the map before you join a team

By: slackiller | Mar 05 2006

Making a camera , Part 2
Half-Life 2 | Level Design
these cameras are working monitors that turn on when a button is pushed.

By: slackiller | Mar 04 2006

Storing weapons on ladder
Half-Life 2 | Coding | Snippets
like Raven Sheild or BF2

By: British_Bomber | Dec 24 2005

Implementation of a string lookup table
Half-Life 2 | Coding | Snippets
A string lookup table is a set of functions that is used to convert strings to pre-defined values

By: deathz0rz | Nov 13 2005


Latest Comments
knock knock
General | News
By: MIFUNE | Dec 31 2017
 
knock knock
General | News
By: omega | Dec 22 2016
 
knock knock
General | News
By: MIFUNE | Oct 10 2015
 
New HL HUD Message System
Half-Life | Coding | Shared Tutorials
By: chbrules | Dec 31 2011
 
knock knock
General | News
By: Whistler | Nov 05 2011
 
Particle Engine tutorial part 4
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 18 2010
 
Particle Engine tutorial part 2
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Particle Engine tutorial part 3
Half-Life | Coding | Client Side Tutorials
By: darkPhoenix | Feb 11 2010
 
Game Movement Series #2: Analog Jumping and Floating
Half-Life 2 | Coding | Shared Tutorials
By: mars3554 | Oct 26 2009
 
Particle Engine tutorial part 5
Half-Life | Coding | Client Side Tutorials
By: Deadpool | Aug 02 2009
 

Site Info
297 Approved Articless
8 Pending Articles
3940 Registered Members
0 People Online (17 guests)
About - Credits - Contact Us

Wavelength version: 3.0.0.9
Valid XHTML 1.0! Valid CSS!