Overview
This guide will walk you through compiling CoD4 Unleashed Server from source code. The build process is straightforward and uses standard compilation tools.Prerequisites
Required Tools
To compile CoD4U-Server, you’ll need the following installed:- gcc (Linux) or mingw32 (Windows)
- nasm (Netwide Assembler)
- libcurl (for HTTP/HTTPS support)
Linux Installation
Debian/Ubuntu 32-bit
Debian/Ubuntu 32-bit
Debian/Ubuntu 64-bit
Debian/Ubuntu 64-bit
Arch Linux 32-bit
Arch Linux 32-bit
Windows Dependencies
For Windows builds, you’ll need to install:- MinGW32 (GCC for Windows)
- NASM (add to PATH)
- OpenSSL 32-bit for runtime: Win32 OpenSSL v1.1.1g or later
Building on Linux
Run the build script
Execute the Linux build script:This script will:
- Compile all C source files with
-m32flag (32-bit) - Assemble all ASM hook files using NASM
- Link everything together with required libraries
- Output the binary to
bin/cod4u_lnx
Build Process Details
The Linux build script performs the following operations:-
C Compilation: Compiles all C files with these flags:
-m32: Build 32-bit binary-O0 -g: No optimization, with debug symbols-fno-omit-frame-pointer: Keep frame pointers for debugging-mtune=nocona: Optimize for Intel Nocona architecture
-
ASM Compilation: Assembles hook files:
qcommon_hooks.asm,cmd_hooks.asm,filesystem_hooks.asmxassets_hooks.asm,trace_hooks.asm,misc_hooks.asmscr_vm_hooks.asm,g_sv_hooks.asm,server_hooks.asmmsg_hooks.asm,pluginexports.asm
-
Linking: Links with required libraries:
libcurl(HTTP/HTTPS support)libtomcrypt_linux,libtommath_linux(cryptography)- Standard libraries:
dl,pthread,m,stdc++
Building on Windows
Set up the environment
Ensure MinGW32 and NASM are in your system PATH. The build script automatically adds NASM from
%LOCALAPPDATA%\nasm.Run the build script
Execute the Windows build script:This script will:
- Compile all C source files for Windows
- Assemble all ASM hook files with COFF format
- Link with Windows-specific libraries
- Create plugin export library
- Output the binary to
bin/cod4u_win32.exe
Windows Build Details
The Windows build differs from Linux in several ways:-
Compiler Flags:
-march=noconainstead of-mtune-D WINVER=0x501: Target Windows XP and later- COFF object format for NASM with
--prefix _
-
Linking:
- Custom linker script:
linkerscript_win32.ld - Image base:
0x8040000 - Windows libraries:
ws2_32,wsock32,gdi32,winmm - Static linking:
-static-libgcc
- Custom linker script:
-
Plugin Support:
- Exports all plugin API functions
- Creates
libcom_plugin.aimport library - Required for developing custom plugins
Compilation Flags
Output Files
After a successful build, you’ll find:| Platform | Binary Location | Size |
|---|---|---|
| Linux | bin/cod4u_lnx | ~2-4 MB |
| Windows | bin/cod4u_win32.exe | ~2-4 MB |
bin/cod4u_win32.def: Export definitionsplugins/libcom_plugin.a: Plugin development library
Troubleshooting Build Issues
Error: Cannot find libcurl
Error: Cannot find libcurl
Make sure libcurl development package is installed:
Error: nasm: command not found
Error: nasm: command not found
Install NASM assembler:
Error: gcc: error: unrecognized command line option '-m32'
Error: gcc: error: unrecognized command line option '-m32'
On 64-bit systems, install 32-bit development tools:
Windows: Missing DLL errors at runtime
Windows: Missing DLL errors at runtime
Install Win32 OpenSSL:
- Download from slproweb.com
- Install Win32 OpenSSL v1.1.1g or later
- Make sure DLLs are in PATH or same directory as exe
Development Builds
The default build configuration is optimized for development:- Debug symbols (
-g): Enabled for debugging - Optimization (
-O0): Disabled for easier debugging - Frame pointers: Kept for better stack traces
Creating Release Builds
For production use, modify the build scripts:Cross-Compilation
You can cross-compile the Windows version from Linux:Next Steps
After successfully building the server:- See Installation for deployment instructions
- Check Configuration for setup options
- Review Troubleshooting if you encounter issues
The build process creates a debug build by default. For production deployments, consider creating an optimized release build with debug symbols stripped.