|
Compiling the source code
So you've downloaded the source code and want to get stuck in. Something stopping you?
If it's your compiler then read on...
If you're lucky then someone has already solved your problem for your compiler. If they've sent us here
at Code3Arena then its on this page somewhere.
If you you do have a problem with something that appears here, ensure you've done
your best first. That means reading all the documentation provided - basically making sure you're
not doing something stupid. Compilers are not "novice" software.
Your compiler might not be here, so try looking at the two part article
(part#1, part#2) by
HypoThermia.
It covers the things you need to know to get the code compiling.
Known problems
Compiler specific material
Other misc. useful stuff
What you're aiming to do
Quake 3 uses a Virtual Machine (QVM) to run most of the game code. This portable ANSI
C source code is compiled into bytecode by an executable LCC.EXE supplied with the source.
This QVM is as platform independent as it gets - and the best way to distribute mods. At the very
least you'll need to get this working with your compilers header files.
If you're using the Win32 platform to develop you can also build binaries in the form of DLLs.
These won't run on the LINUX or Mac versions of Quake3 (so they're not recommended
for distribution), but can let you use your compiler to debug code.
Batch files for 1.29/1.30 that work with MSVC
e.n.g.e.l has sent in the updated compiling batch files for
release 1.29/1.30 of the Q3 source code. The batch files also work for Team Arena. He's also included fixes for a few of the
compiler errors that have crept into this source code release... mostly missing const
qualifiers. Oh, and the missing bin/lcc tools are also supplied.
You can grab the files from FilePlanet as
q3compiling_129h.zip (287k).
Batchfiles for 1.27 that work with MSVC
Thanks to the efforts of Simon Hopwood
we've now got batch files that do actually compile the Q3 source. These are intended for use with
MSVC, the "standard" compiler used for building Q3 binaries. They replace the existing
ones provided by Id.
Projects and batch files for the Borland tools can be found at the
section near the bottom of the page.
Download the version
you need for the source you're working on:
q3batchfiles_127g.zip for
1.27g source code, compiles either TA or standard Q3 versions of the QVM. Also include
the missing tools in source/lcc/bin (278K).
Can't find cpp.exe or compiler tools when compiling the VM
The 1.27 release of the source code didn't have the compiler tools
needed to actually compile the code! The easiest way to get your hands on
them is to get an old copy of the 1.17 source code and follow these
steps:
- Install the old source code into a dummy directory. This avoids any problems with your existing 1.27 installation.
- Find the subdirectory "source/lcc/bin"
- Copy over the contents (keeping the dir structure) to your 1.27 directory.
The code should now find the executables that it needs to compile the VM.
Compiling VM gives error "#line 1 <stdin>"
This is a pretty obscure error that turns up when you compile the VM.
The batch files stop compiling on the first file and sit there waiting
for keyboard input, with this error message:
#line 1 <stdin>
Here's what Neils has to say about the problem and how to fix it:
The problem comes when you install the MS Platform SDK or something similar (anything that
sets up the LIBRARY and INCLUDE envronment vars). So the solution is very simple: Add these
two lines to the top of Game.Bat and the other batch-files used to compile the QVM files:
set LIBRARY=
set INCLUDE=
|
So there ya go... thanks to Neils (G4S) for sending in that info!
Compiling 1.27 code
I've put together an article
about as many of the known problems with 1.27 source as I've been able
to find. It includes tips on how to get the code compiling with MSVC, as
well as some of the coding errors that you might find.
Compiling the QVM's for 1.16 and 1.17 fails
A few people have reported this, and Kukaracha
has brought the solution to our
attention (Thanks!). Each of the batch files used to compile the respective QVMs (ui.bat, game.bat,
and cgame.bat) were changed between 1.15 and 1.16. This change "broke" the compilation
process.
This is what Kukaracha has to say, taken from
his original article on Quake3World:
|
I had the first release of the game source and I could modify and compile it fine. Then I downloaded the 1.17
source and I couldn't compile.
I looked in the cgame, game and ui batch files and saw this line:
set cc=lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1
In a dos prompt in win98 I get a syntax error. This is
because of the "=" in -Wf-target=bytecode
So I changed the line to this:
@set cc=call ..\compile.bat %1
and created a compile.bat almost like in the old source (All on one line in the batch file):
lcc -DQ3_VM -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1
and copied it to the cgame, game and ui directories.
The vms then dutifully compiled.
|
You'll have to change the set cc= in each of ui.bat, cgame.bat and game.bat
to get the source code to compile.
'Out of environment space' error
This error sometimes creeps in when you run the batch files from within Windows,
usually when you try and run vars.bat.
The fix is straight forward, you'll need to start with an explorer window open in
the directory with the offending batch file (the one you are running).
- Create a link to the batch file. Do this by right-clicking on the batch file
and select Create shortcut. The new shortcut should match the name of the batch
file and have an MSDOS icon.
- Rename the shortcut and remove the .bat extension.
- Right-click on this shortcut and select properties.
- Choose the memory tab and increase the Initial environment value
from the default Auto to something like 3000 or 4000.
- If you want to see the contents of the DOS window after the batch
file has run, select the Program tab and make sure the Close
on exit checkbox is clear.
- If you want the batch file to run in a window instead of fullscreen,
select the Screen tab and make sure the Window radio-button
is set.
- Save your changes by pressing OK.
You should now find the batch file will run without error messages, whether you
run the new shortcut or the original batch file.
For those who are curious about whats going on, here's a more detailed
explanation:
The shortcut to an old DOS executable or batch file sets up the environment
in which the program runs. This shortcut is equivalent to the PIF file in the
old Win3.1 way of doing things. Every time you run the old DOS program, Windows
searches for an environment (in the form of the program name without any extension),
and uses this automatically.
Microsoft Visual C++
When Id wrote Q3 they were using Microsoft Visual C++ for Windows to develop
and test the Win32 code. If you've got this compiler then you shouldn't have problems
getting going. Tutorial#2
by SumFuka should help.
Borland C++ v5.0
This compiler causes only minor problems when using its header files on the bytecode.
More seriously, there is an error generated by the math library that appears to pauses the
game making it appear to hang. It can be fixed by adding a math error handler (this problem
was fixed in the binary release v1.16).
You can get the files and a project IDE from the downloads page.
There are full installation and setup instructions in the package, as well as a makefile for
the command line tools.
Borland C++ v4.5 doesn't handle long filenames properly, so no project file is available.
Update: a project and batch files are now available for the 1.27 source code. You can get
either standard Q3 or Team Arena builds, so go grab it now from the
download page.
Borland C++ v5.5 command line tools
Borland/Inprise recently released their industrial strength compiler commmand line tools free of charge -
a boon to C/C++ developers. The downloads page
includes a makefile that works with these tools, and allows you to compile binary DLLs
from the command line.
Christopher Przybycien
sent in the following on how to get LCC working with the header files from that distribution.
You'll need to set up the download for Borland C++ 5.0 (above) as it's a modification for that.
|
IMPORTANT: DO NOT MODIFY THE ORIGINAL CTYPE.H! DO AS IT SAYS IN THE STEPS
BELOW!
- copy [bcc 5.5 dir]\Include\ctype.h to the quake3\source\borland
directory.
- open the copy you just made up and at line 161, change the line:
#if defined( __USELOCALES__ )
to:
#if defined( __USELOCALES__ ) && ! defined (__BORLANDC__)
- save.
- next, open up compile.bat and put a "-I.." somewhere before
"-Ie:\bc5\include".
- save.
misc notes:
Apparently lcc doesn't understand the weird inline function thing or
perhaps the pragma directives (dear god why does this thing exist still?)
around borland's function prototypes for tolower and toupper and some
others. So what this little hack does is disable borland's
toupper/tolower/et al and use id's own. We stick the "-I.." in compile.bat
so that lcc looks in the current directory for our modified ctype.h before
the borland \include directory. The reason we make a copy of ctype.h and
modify that is because if you modified the original ctype.h in this manner,
it would seriously screw up bcc5.5.
one more thing, lcc bitches like crazy about .h files without a newline at
the end. You can ignore these cause it still compiles. and one last thing,
that hack gets it working for making vm bytecode, i haven't tried building
the dlls heh.
|
Compiling with MetroWerks CodeWarrior
For those of you that want an integrated development environment, but can't
afford Microsoft VC++ or Borland C++, then there's an alternative in the form
of MetroWerks CodeWarrior.
Tony Kostanjsek has
written an article
about setting up CodeWarrior. It includes a CodeWarrior project, and some
plugins (with source) you can download to help you get started.
He's put a lot of hard work into this, so drop him a line of thanks if
you find it useful.
A simple setup for compiling QVMs
More from Tony Kostanjsek, this
time on compiling QVMs using the lcc compiler provided with the Q3 source
distribution. You'll need to grab the file from the link below:
|
This is for people who don't have any of the IDEs mentioned in other articles,
are still experiencing problems with their compilers source files, or
want to work in a minimalistic environment.
Lcc is a free implementation of a C-Compiler whose sources you can easily find
on the net. There's also a book about it, explaining the implementation in
detail. The guys at Id have modified lcc to suit their needs and wrote
q3asm, a linker for the bytecode files.
The sources as provided by Id need some additional headers. In the
ReadMe it says you should setup your paths to point to the
VC++ includes. This is not the only way to enable QVM compilation!
Rather than trying to feed our favourite compilers headers into lcc
and watch it choke, we can simply use the headers that come with lcc
to compile the QVMs. Download these
lcc-headers (8kb)
and unzip them into quake3/source/lcc/bin/include. Lcc will
automatically find them. Now set up PATH to point to
quake3/bin_nt and in all the compile.bat scripts change
the lcc call to include -D_stdcall= . This will define
_stdcall to nothing so it doesn't come in our way. Run the
appropriate compile scripts (cgame.bat etc.) and you're done!
Most of this info was posted on the quake3world.com community pages
by some nice people, along with links to lcc distributions.
I just put it together here. The headers were slightly modified
to work with the Q3 sources. Thanks to my leaky brain I can
neither remember the names of the people who posted this first,
nor the distribution I took the headers from or what I changed
to make them work. Could be worse.
Have fun!
|
Compiling with Linux tools
With Id's game available to play on the Linux platform, it only makes
sense that you should be able to compile it there as well! Timbo has
corrected that gap at C3A by putting together the things that you
need to do the job.
You can grab them from
his web site and start working on your Q3 project in your favourite OS.
A simple batch file for compiling all QVMs
A simple but useful batch file from Slagman,
it allows you to compile all three QVMs in one go. Put it in the working directory
for your project, i.e. the one that contains the ui, cgame, and game
directories. Call it something relevant like compile_all.bat.
It will work with the default configuration, but needs a little modification if
you're using Borland tools above.
@ECHO OFF
cd cgame
CALL cgame.bat
cd..
cd game
CALL game.bat
cd..
cd ui
CALL ui.bat
|
Compiling under NTFS?
For those of you trying to compile the source code on an NT box using
an NTFS drive. Demon Cat
has this experience to pass on:
I recently moved my mod source to a new computer. Copied the quake3
directory verbatim from one NT machine w/ Service Pack 6 to another. But
the mod that worked just fine on the old system wouldn't compile on the
new one, giving file not found errors for files I knew were there.
After trying everything I could think of toensure that it *should* be
able to compile, I finally figured out the issue: NTFS. It worked just
fine once I moved it to a FAT partition on the same computer.
|
|