PlanetQuake | Code3Arena | Articles | << Prev | Article 10 | Next >>


  • Home/News
  • ModSource
  • Compiling
  • Help!!!
  • Submission
  • Contributors
  • Staff
  • Downloads

    < Index >
    1. Mod making 101
    2. Up 'n running
    3. Hello, QWorld!
    4. Infinite Haste
    5. Armor Piercing Rails
    6. Bouncing Rockets
    7. Cloaking
    8. Ladders
    9. Favourite Server
    10. Flame Thrower
    11. Vortex Grenades
    12. Grapple
    13. Lightning Discharge
    14. Locational Damage
    15. Leg Shots
    16. Weapon Switching
    17. Scoreboard frag-rate
    18. Vortex Grenades II
    19. Vulnerable Missiles
    20. Creating Classes
    21. Scrolling Credits
    22. Weapon Dropping
    23. Anti-Gravity Boots
    24. HUD scoreboard
    25. Flashlight and laser
    26. Weapon Positioning
    27. Weapon Reloading
    28. Progressive Zooming
    29. Rotating Doors
    30. Beheading (headshot!)
    31. Alt Weapon Fire
    32. Popup Menus I
    33. Popup Menus II
    34. Cluster Grenades
    35. Homing Rockets
    36. Spreadfire Powerup
    37. Instagib gameplay
    38. Accelerating rockets
    39. Server only Instagib
    40. Advanced Grapple Hook
    41. Unlagging your mod

    < Index >
    1. Entities
    2. Vectors
    3. Good Coding
    4. Compilers I
    5. Compilers II
    6. UI Menu Primer I
    7. UI Menu Primer II
    8. UI Menu Primer III
    9. QVM Communication, Cvars, commands
    10. Metrowerks CodeWarrior
    11. 1.27g code, bugs, batch


  • Quake3 Files
  • Quake3 Forums
  • Q3A Editing Message Board
  • Quake3 Editing


  • SumFuka
  • Calrathan
  • HypoThermia
  • WarZone

    Site Design by:
    ICEmosis Design

    ARTICLE 10 - Compiling with Metrowerks CodeWarrior
    by Tony Kostanjsek

    CodeWarrior is cool. This is for all the people who also appreciate its features and want to use it for Q3 development. I assume that you know how to set up a mod, where to put DLLs and QVMs and how to start quake so it actually finds and loads your files. In the following text you'll only find the details you need to take your work to the CodeWarrior IDE. Contact me if you have any further questions or spotted any mistakes.

    But before we continue, heres some additional info you might want to know:

    CodeWarrior: is a Compiler/IDE made by Metrowerks. It runs on various platforms including MacOS, Windows, Solaris and as a front-end for the Linux GNU compilers. It allows you to build projects for various platforms including Java, PalmOS, Playstation and others besides the ones you're using to run the IDE.

    The IDE has lots of useful features that make it very easy to navigate between source files, very powerful search functions, manage groups of files and targets. And I mean VERY easy and VERY powerful compared to (say) VC++. Grab a copy and try it.

    Lcc: is a retargetable C compiler by Chris Fraser and David Hanson. For more infos, distributions, source code, documentation and books about it, head to the Lcc pages at Our friends at Id have modified it to spit out QVM bytecode as we know it.


    1. Building DLLs

    The following steps were only tested for release builds. I haven't tried using the debugger while running Quake3 in a window.

    Follow these steps to build a server DLL:

    1. create a Win32 C DLL Project as the starting point
    2. select the 'Win32 C DLL Release' target
    3. delete the 'Win32 C DLL Debug' target. We don't need it.
    4. open the preferences of the current target
    5. in 'Target/Target Settings' change the 'Target Name' to 'server'
    6. in the same panel set the output directory to the one of your mod
    7. in 'Target/x86 Target' change the 'File Name' to 'qagamex86.dll'. The names for the other DLLs are 'cgamex86.dll' and 'uix86.dll'
    8. in 'Code Generation/x86 Processor' set Byte Alignment to '4'. I was successfully running DLLs with the default '8', but Hypothermia pointed out that Q3 requires '4' so we'll set it.
    9. in 'Language Settings/C/C++ Language' enable 'Enums always int'
    10. in the same panel, remove the prefix file (Win32Headers.mch or similar) or you'll get multiple defines.
    11. CodeWarrior has some cool keyword highlighting features. If you want to use them, go to 'Target/Build Extras' and check 'Activate Browser'
    12. save the preferences and close them
    13. remove all files from the 'Source' folder in your project window and rename the folder to 'Server'
    14. now open the 'game.bat' file that comes with the sources and is used to compile the QVMs. You'll see a list of .c files. Find all of them in the 'quake3/source/game' folder and drop them in your project window in the 'Server' folder.
    15. don't put in 'bg_lib.c' as it only includes stdlib functions we already have in the libs.
    16. add 'g_syscalls.c' to the server target, 'cg_syscalls.c' to the client and 'ui_syscalls.c' to the ui. These enable your DLLs to call the trap_* functions that talk to the Q3 core.
    17. add the 'game.def' file along with the .c files, otherwise the compiler won't know which symbols to export and Q3 won't be able to load our DLL
    18. open the 'Win32 SDK Libraries' folder in the project window and remove the 'Gdi32.lib'. We don't need it. Required libraries are: Ansicx86.lib, Mwcrtl.lib, Kernel32.lib, User32.lib
    19. build the DLL, start the mod with something like: C:\quake3\quake3.exe +sv_pure 0 +set fs_game MyModFolder. Always set +sv_pure 0 if you're trying your own maps and mods to avoid problems.
    20. Voilà!
    Building targets for client and ui DLLs is just the same. If you can't be bothered to set up a project yourself, download this cwq3project (13kb). Make a copy of the original sources. Assuming that your mod's sources are located in the folder 'CoolMod', create a folder 'cwq3project' inside 'CoolMod'. Unzip '' inside 'CoolMod/cwq3project' and you're done. You can rename the folder 'cwq3project' and 'cwq3project.mcp' to whatever you like. You should keep the extra folder inside 'CoolMod' because CodeWarrior creates some additional project data thats stored inside it.


    2. Building QVMs

    The ReadMe provided with the sources suggests that you use the VC++ headers to compile the QVMs. At first I thought I could also get lcc to compile with the MSL headers, but it wouldn't work. The '__option' switches made it abort compilation, and I didn't succeed in defining a valid set of switches so the cross platform headers would turn into something useful.

    After some research I decided to go with the lcc-headers (8kb). Put them in quake3/source/lcc/bin/include and in all compile.bat files add -D_stdcall="" to the command line. Now you can use the .bat files to compile your QVMs just as you were supposed to.

    But is this really it? Didn't we get a groovy IDE to avoid .bat files? Yup! That's why I downloaded the Metrowerks PlugIn SDK and wrote some ...


    3. IDE PlugIns for the Q3 tools


    These are really front-ends for lcc and q3asm that make them look like an integral part of the IDE. Kinda.

    Download the cwq3plugins (85kb) and the PlugIn-Sources (55kb) here and put them in your CW PlugIns-Folder. The sources also include a sample project.

    Unfortunately there are some drawbacks....


    It's not my fault, honestly! Or ... at least I don't know what I did wrong. Look at the following:

    1. Paths: The IDE does a lot for you. It also does a lot for its PlugIns. It takes care of the access paths and if a PlugIn says 'gimme file deathwish.h' it'll find and load it and pass it a handle to the file. Unfortunately, we're not a true compiler, only a front-end. And as the IDE won't give us the paths, just the files, you have to enter the whole lcc command line parameters in the cwq3panel, complete with include paths.

      That sucks!

    2. Performance: Again, we're only a front-end. The tools are started as child processes and their output is redirected to the message window. Process maintenance and output redirection takes a while. Worst case for q3asm on my machine was nearly 60 seconds compared to 20 seconds if you use the .bat files. Lcc is also a lot slower.

      Very stupid!

    The performance is the main reason why I can't really advise you to use the PlugIns for frequent use. You should rather build DLLs until the final release. Then, you could build the QVMs with the .bats or with new targets that use the PlugIns.

    In fact, I was so disappointed with the performance and the restricted access to the path settings that I left the PlugIns in an unpolished state. They work, but could do with some tidying up. For example, there is no panel for controlling the lcc or q3asm flags via checkboxes etc. Instead, you have to specify everything in a command line string. Theres also no way yet to select folders through a dialog. You have to enter the pathnames manually.

    So, if anyone wants to take a look at the sources and see if theres a way to optimize things, feel free to do so and please share your new versions.

    Anyway, you should really stop messing around with that compiler and get coding your mod! NOW!

    PlanetQuake | Code3Arena | Articles | << Prev | Article 10 | Next >>