|
| 1 | +# Build Command & Conquer Generals on Linux |
| 2 | + |
| 3 | +This guide covers building Generals and Zero Hour on Linux using Docker. The build produces Windows |
| 4 | +executables that can run natively on Windows or under Wine on Linux. |
| 5 | + |
| 6 | +## Quick Start |
| 7 | + |
| 8 | +The repository includes convenience scripts that automate the Docker build process: |
| 9 | + |
| 10 | +```bash |
| 11 | +# Clone the repository |
| 12 | +git clone https://github.com/TheSuperHackers/GeneralsGameCode.git |
| 13 | +cd GeneralsGameCode |
| 14 | + |
| 15 | +# Build using Docker (produces Windows executables) |
| 16 | +./scripts/docker-build.sh |
| 17 | + |
| 18 | +# Install to your game (auto-detects Wine prefix) |
| 19 | +./scripts/docker-install.sh --detect |
| 20 | +``` |
| 21 | + |
| 22 | +## Prerequisites |
| 23 | + |
| 24 | +- **Docker**: Install Docker Engine for your distribution |
| 25 | + - [Debian/Ubuntu](https://docs.docker.com/engine/install/debian/) |
| 26 | + - [Fedora](https://docs.docker.com/engine/install/fedora/) |
| 27 | + - [Arch Linux](https://wiki.archlinux.org/title/Docker) |
| 28 | +- **Git**: For cloning the repository |
| 29 | +- **Wine** (optional): For running the built executables on Linux |
| 30 | + |
| 31 | +### Docker Setup |
| 32 | + |
| 33 | +Ensure Docker is running and your user has permission: |
| 34 | + |
| 35 | +```bash |
| 36 | +# Start Docker daemon |
| 37 | +sudo systemctl start docker |
| 38 | + |
| 39 | +# Add your user to the docker group (logout/login required) |
| 40 | +sudo usermod -aG docker $USER |
| 41 | +``` |
| 42 | + |
| 43 | +## Build Scripts |
| 44 | + |
| 45 | +### docker-build.sh |
| 46 | + |
| 47 | +The main build script that manages the Docker-based build process. |
| 48 | + |
| 49 | +```bash |
| 50 | +# Full build (both Generals and Zero Hour) |
| 51 | +./scripts/docker-build.sh |
| 52 | + |
| 53 | +# Build Zero Hour only |
| 54 | +./scripts/docker-build.sh --game zh |
| 55 | + |
| 56 | +# Build Generals only |
| 57 | +./scripts/docker-build.sh --game generals |
| 58 | + |
| 59 | +# Build specific target |
| 60 | +./scripts/docker-build.sh --target generalszh |
| 61 | + |
| 62 | +# Clean build directory first |
| 63 | +./scripts/docker-build.sh --clean |
| 64 | + |
| 65 | +# Force CMake reconfiguration |
| 66 | +./scripts/docker-build.sh --cmake |
| 67 | + |
| 68 | +# Enter container shell for debugging |
| 69 | +./scripts/docker-build.sh --interactive |
| 70 | +``` |
| 71 | + |
| 72 | +Build outputs are placed in `build/docker/`: |
| 73 | + |
| 74 | +| Directory | Contents | |
| 75 | +| --------------------------- | ---------------------- | |
| 76 | +| `build/docker/GeneralsMD/` | Zero Hour executables | |
| 77 | +| `build/docker/Generals/` | Generals executables | |
| 78 | +| `build/docker/Core/` | Shared DLLs | |
| 79 | + |
| 80 | +### docker-install.sh |
| 81 | + |
| 82 | +Installs built executables to an existing game installation. |
| 83 | + |
| 84 | +```bash |
| 85 | +# Auto-detect game location (checks Wine prefixes and common paths) |
| 86 | +./scripts/docker-install.sh --detect |
| 87 | + |
| 88 | +# Specify game directory manually |
| 89 | +./scripts/docker-install.sh /path/to/game |
| 90 | + |
| 91 | +# Install Generals instead of Zero Hour |
| 92 | +./scripts/docker-install.sh --game generals /path/to/game |
| 93 | + |
| 94 | +# Dry run (show what would be installed) |
| 95 | +./scripts/docker-install.sh --dry-run --detect |
| 96 | + |
| 97 | +# Restore original files from backups |
| 98 | +./scripts/docker-install.sh --restore /path/to/game |
| 99 | +``` |
| 100 | + |
| 101 | +The script will: |
| 102 | + |
| 103 | +1. Backup your original executables (`.exe.backup`) |
| 104 | +2. Copy newly built executables |
| 105 | +3. Copy new DLLs (DebugWindow.dll, ParticleEditor.dll) |
| 106 | +4. Preserve original mss32.dll and binkw32.dll (audio/video libraries) |
| 107 | + |
| 108 | +## Running the Game |
| 109 | + |
| 110 | +After building and installing, run the game with Wine: |
| 111 | + |
| 112 | +```bash |
| 113 | +# Zero Hour (path depends on your installation) |
| 114 | +wine /path/to/game/generalszh.exe |
| 115 | + |
| 116 | +# Or from the build directory (requires game data files) |
| 117 | +wine build/docker/GeneralsMD/generalszh.exe |
| 118 | +``` |
| 119 | + |
| 120 | +### Wine Configuration |
| 121 | + |
| 122 | +For best results: |
| 123 | + |
| 124 | +```bash |
| 125 | +# Use 32-bit Wine prefix |
| 126 | +WINEARCH=win32 WINEPREFIX=~/.wine-generals winecfg |
| 127 | + |
| 128 | +# Set Windows version to Windows XP or Windows 7 |
| 129 | +winecfg |
| 130 | +``` |
| 131 | + |
| 132 | +## Troubleshooting |
| 133 | + |
| 134 | +### Docker Permission Denied |
| 135 | + |
| 136 | +```text |
| 137 | +Got permission denied while trying to connect to the Docker daemon |
| 138 | +``` |
| 139 | + |
| 140 | +Solution: Add your user to the docker group and re-login: |
| 141 | + |
| 142 | +```bash |
| 143 | +sudo usermod -aG docker $USER |
| 144 | +# Then logout and login again |
| 145 | +``` |
| 146 | + |
| 147 | +### Build Directory Not Found |
| 148 | + |
| 149 | +```text |
| 150 | +Build directory not found: /path/to/GeneralsGameCode/build/docker |
| 151 | +``` |
| 152 | + |
| 153 | +Solution: Run the build script first: |
| 154 | + |
| 155 | +```bash |
| 156 | +./scripts/docker-build.sh |
| 157 | +``` |
| 158 | + |
| 159 | +### Game Not Found |
| 160 | + |
| 161 | +```text |
| 162 | +No game installation found |
| 163 | +``` |
| 164 | + |
| 165 | +Solution: Specify the game directory manually: |
| 166 | + |
| 167 | +```bash |
| 168 | +./scripts/docker-install.sh /path/to/your/game/installation |
| 169 | +``` |
| 170 | + |
| 171 | +### Wine Errors |
| 172 | + |
| 173 | +If the game crashes or has graphical issues: |
| 174 | + |
| 175 | +1. Try different Wine versions (wine-staging often works better for games) |
| 176 | +2. Install required dependencies: `winetricks directx9 vcrun6` |
| 177 | +3. Use DXVK for better DirectX performance: `winetricks dxvk` |
| 178 | + |
| 179 | +## Manual Docker Build |
| 180 | + |
| 181 | +If you prefer to run the Docker commands manually instead of using the scripts: |
| 182 | + |
| 183 | +```bash |
| 184 | +# Build the Docker image |
| 185 | +docker build \ |
| 186 | + --build-arg UID=$(id -u) \ |
| 187 | + --build-arg GID=$(id -g) \ |
| 188 | + resources/dockerbuild \ |
| 189 | + -t zerohour-build |
| 190 | + |
| 191 | +# Run the build |
| 192 | +docker run \ |
| 193 | + -u $(id -u):$(id -g) \ |
| 194 | + -v $(pwd):/build/cnc \ |
| 195 | + --rm \ |
| 196 | + zerohour-build |
| 197 | + |
| 198 | +# Enter container for debugging |
| 199 | +docker run \ |
| 200 | + -u $(id -u):$(id -g) \ |
| 201 | + -v $(pwd):/build/cnc \ |
| 202 | + --rm \ |
| 203 | + -it \ |
| 204 | + --entrypoint bash \ |
| 205 | + zerohour-build |
| 206 | +``` |
| 207 | + |
| 208 | +## See Also |
| 209 | + |
| 210 | +- [Build with VC6 on Docker](build_with_msvc6_on_docker.md) - Manual Docker setup |
| 211 | +- [Build Configuration](build_configuration.md) - CMake presets and options |
| 212 | +- [Build Guides](build_guides.md) - All build guides |
0 commit comments