diff --git a/SourceCode/Builds/build_configuration.md b/SourceCode/Builds/build_configuration.md index 7ec5039d..157ce469 100644 --- a/SourceCode/Builds/build_configuration.md +++ b/SourceCode/Builds/build_configuration.md @@ -1,113 +1,113 @@ # Build Configurations Overview -This page describes the various build configurations used in the project, detailing the different types of builds, their -purpose, and the associated compiler flags for each configuration. These configurations control how the code is compiled -and optimized for different development and release scenarios. +This page describes the build configurations GeneralsGameCode supports and the CMake options that control them. For +presets, targets, and installation, see the [Building with CMake guide](cmake_guide). -## Build Configurations +Configurations are selected through CMake cache variables, which the presets in `CMakePresets.json` set for you. You +rarely need to set them by hand; pass them while configuring only when you want a combination no preset provides. -There are four main build configurations in the project, each designed for different purposes: +## Configurations -### 1. **Release (O2, _RELEASE)** +| Configuration | VC6 preset | Win32 preset | Cache variables set by the preset | +| ------------- | ------------- | --------------- | ------------------------------------------------------- | +| Release | `vc6` | `win32` | none; this is the default | +| Debug | `vc6-debug` | `win32-debug` | `RTS_BUILD_OPTION_DEBUG=ON` | +| Profile | `vc6-profile` | `win32-profile` | `RTS_BUILD_OPTION_PROFILE=ON` | -- **Purpose:** The release configuration is used for building the final version of the game that will be distributed to - end users. -- **Features:** - - Maximum optimization (`/O2`) for better performance. - - No debugging information is included to ensure smaller binary size and improved performance. - - Suitable for production builds. +Two differences between the toolchains are worth noting: -- **Compiler Flags:** - - `/O2`: Optimization for speed. - - `/D "_RELEASE"`: Defines the release configuration. - - `/D "NDEBUG"`: Disables debugging code. +- `vc6-debug` also sets `CMAKE_BUILD_TYPE=Debug`, because the VC6 presets use Ninja, a single-configuration generator. + The `win32` presets are multi-configuration, so the configuration is chosen when building instead. +- `win32-profile` additionally sets `RTS_BUILD_OPTION_PROFILE_TRACY=ON`. The VC6 profile build does not use Tracy. -- **Use Case:** This configuration is used when preparing the game for release to the end user. +> **Retail compatibility:** Only the `vc6` Release build is compatible with retail multiplayer and replays. See +> [Build presets](cmake_guide#build-presets). -### 2. **Debug (Od, _DEBUG)** +## Configuration definitions -- **Purpose:** The debug configuration is used for development and debugging. It includes debugging symbols and disables - optimizations to make it easier to step through code. -- **Features:** - - No optimization (`/Od`), making debugging easier but with slower execution. - - Debugging symbols and additional information are included to help track issues. - - The build is less efficient but provides full access to debugging features. +Each configuration compiles the code with a different set of preprocessor definitions: -- **Compiler Flags:** - - `/Od`: Disables optimizations to facilitate debugging. - - `/D "_DEBUG"`: Defines the debug configuration. - - `/ZI`: Generates debugging information. - - `/Gm`: Enables minimal rebuilds. +| Configuration | Definitions | +| ------------- | ---------------------------------------------- | +| Release | `RTS_RELEASE`, `NDEBUG` | +| Debug | `RTS_DEBUG`, `WWDEBUG`, `DEBUG` | +| Profile | `RTS_RELEASE`, `NDEBUG`, `RTS_PROFILE_LEGACY` | -- **Use Case:** Used during development for debugging and resolving issues in the code. +The Profile configuration builds on Release, so it defines `RTS_RELEASE` and `NDEBUG` as well. -> **⚠️ Debug Build Requirements:** To run a debug build of the game, you need to have -> the following two files in the game directory alongside the built executable: -> -> - [`MSVCRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCRTD.DLL) -> Microsoft Visual C++ Runtime Library (Debug) -> - [`MSVCIRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCIRTD.DLL) -> Microsoft Visual C++ Internationalization Runtime Library (Debug) +Two further definitions are applied by platform rather than by configuration: -### 3. **Profile (O2, IG_DEBUG_STACKTRACE, _RELEASE, _PROFILE)** +- On MSVC: `_CRT_NONSTDC_NO_WARNINGS` and `_CRT_SECURE_NO_WARNINGS`, plus `_DEBUG_CRT` in the Debug configuration. +- On Unix: `_UNIX`. -- **Purpose:** The profile configuration is used for performance profiling and optimization. It is designed to help - developers analyze performance bottlenecks and gather performance data. -- **Features:** - - Includes optimization (`/O2`) and performance profiling flags. - - Supports detailed stack tracing (`IG_DEBUG_STACKTRACE`) to gather performance metrics. - - Designed for analyzing how the game performs under various conditions and measuring optimization effectiveness. +> [!NOTE] +> Optimization and debug-information flags such as `/O2`, `/Od`, and `/Zi` are not set by the project. They come +> from the compiler defaults CMake applies for the selected `CMAKE_BUILD_TYPE`. The presets set warning level `/W3` +> through the `RTS_FLAGS` cache variable. -- **Compiler Flags:** - - `/O2`: Optimization for performance. - - `/D "_PROFILE"`: Enables profiling configuration. - - `/D "IG_DEBUG_STACKTRACE"`: Enables stack trace debugging for performance analysis. - - `/D "NDEBUG"`: Disables debugging code in the final build. +The Debug configuration has one additional runtime requirement. -- **Use Case:** Used for profiling and performance analysis to optimize code and identify potential bottlenecks. +> [!IMPORTANT] +> Debug builds require the Microsoft debug runtime libraries in the same directory as the built executable. +> See [VC6 Debug runtime](cmake_guide#vc6-debug-runtime) for the required files. ---- +## Build options -## Key Compiler Flags +These options change how the code is built. All default to `OFF`. -Below is a list of the key compiler flags used across different configurations: +| Option | Effect | +| --------------------------------- | ------------------------------------------------------------------- | +| `RTS_BUILD_OPTION_DEBUG` | Builds the Debug configuration | +| `RTS_BUILD_OPTION_PROFILE` | Builds the Profile configuration | +| `RTS_BUILD_OPTION_PROFILE_TRACY` | Enables Tracy profiler integration | +| `RTS_BUILD_OPTION_ASAN` | Builds with Address Sanitizer (`/fsanitize=address`) | +| `RTS_BUILD_OPTION_VC6_FULL_DEBUG` | Builds VC6 with full debug information (`/Zi`) | +| `RTS_BUILD_OPTION_FFMPEG` | Enables FFmpeg support | -### Optimization Flags +There is also `RTS_BUILD_OUTPUT_SUFFIX`, a string appended to the output names of installable targets. It is empty by +default, which is why the executables are named `generalsv.exe` and `generalszh.exe`. -- **`/O2`**: Optimizes the code for speed. This flag is typically used in release builds and performance profiling - builds. -- **`/Od`**: Disables optimizations, which is useful during debugging when you want to ensure that the debugger can - easily track code execution. +## Debug feature options -### Debugging Flags +These options control individual debug features independently of the configuration, so a Release build can keep +logging or assert dialogs enabled. -- **`/D "_DEBUG"`**: Defines the build as a debug version, enabling debugging-specific features in the code. -- **`/D "_RELEASE"`**: Defines the build as a release version, disabling debugging features and optimizing for - performance. -- **`/D "NDEBUG"`**: Disables debugging code, typically used in release builds. +The following four accept `DEFAULT`, `ON`, or `OFF`. `DEFAULT` leaves the feature to the configuration, where it is +enabled for Debug and Internal builds: -### Profiling Flags +| Option | `ON` defines | `OFF` defines | +| ---------------------- | ------------------- | --------------------------- | +| `RTS_DEBUG_LOGGING` | `DEBUG_LOGGING` | `DISABLE_DEBUG_LOGGING` | +| `RTS_DEBUG_CRASHING` | `DEBUG_CRASHING` | `DISABLE_DEBUG_CRASHING` | +| `RTS_DEBUG_STACKTRACE` | `DEBUG_STACKTRACE` | `DISABLE_DEBUG_STACKTRACE` | +| `RTS_DEBUG_PROFILE` | `DEBUG_PROFILE` | `DISABLE_DEBUG_PROFILE` | -- **`/D "_PROFILE"`**: Enables performance profiling in the build. This flag is used to gather performance data during - runtime. -- **`/D "IG_DEBUG_STACKTRACE"`**: Enables stack trace generation, which helps in analyzing performance issues and - crashes. +Each of these definitions is set to `1`. Enabling `RTS_DEBUG_STACKTRACE` also enables debug logging. -### Additional Flags +The remaining options are simple on/off switches, all `OFF` by default: -- **`/ZI`**: Generates debugging information and supports editing and continuing in Visual Studio. -- **`/WX`**: Treats warnings as errors, which is often used to enforce strict coding standards. -- **`/Gm`**: Enables minimal rebuild, allowing faster incremental builds. -- **`/MD`**: Links with the dynamic version of the C runtime library, commonly used for Windows builds. -- **`/Yu"PreRTS.h"`**: Tells the compiler to use precompiled headers, which can speed up compilation time. +| Option | Defines | Purpose | +| ---------------------------------------- | -------------------------------- | ---------------------------------------- | +| `RTS_DEBUG_CHEATS` | `_ALLOW_DEBUG_CHEATS_IN_RELEASE` | Enables debug cheats in release builds | +| `RTS_DEBUG_INCLUDE_DEBUG_LOG_IN_CRC_LOG` | `INCLUDE_DEBUG_LOG_IN_CRC_LOG` | Includes the debug log in the CRC log | +| `RTS_DEBUG_MULTI_INSTANCE` | `RTS_MULTI_INSTANCE` | Allows running multiple client instances | ---- +## Additional presets -## When to Use Each Configuration +Two VC6 presets combine a Release build with debug features: -- **Release:** Use this configuration when preparing the final version of the game for distribution. It ensures the game - is optimized for performance with no debugging overhead. -- **Debug:** Use this configuration during development when you need to debug issues. It disables optimizations and - includes debugging information. -- **Profile:** Use this configuration when analyzing the performance of the game. It helps identify bottlenecks and - areas that can be optimized further. +| Preset | Cache variables | Purpose | +| ----------------- | ------------------------------------------------ | ---------------------------------------- | +| `vc6-releaselog` | `RTS_DEBUG_LOGGING=ON`, `RTS_DEBUG_CRASHING=ON` | Release build with logging and asserts | +| `vc6-weekly` | `RTS_BUILD_OPTION_VC6_FULL_DEBUG=ON` | Release build with full debug info | + +List every preset in your checkout with `cmake --list-presets=all`. + +## Example + +Configure a Release build with debug logging enabled and build it: + +```shell +cmake --preset vc6 -DRTS_DEBUG_LOGGING=ON +cmake --build --preset vc6 +``` diff --git a/SourceCode/Builds/build_guides.md b/SourceCode/Builds/build_guides.md index 9bc6a6a5..59c234e2 100644 --- a/SourceCode/Builds/build_guides.md +++ b/SourceCode/Builds/build_guides.md @@ -1,94 +1,32 @@ # Build Guides -This page provides an overview of the official and community-supported build guides for **TheSuperHackers** project. It -includes both the official build guides for the main repository and guides for community forks of the project. The -guides cover different environments, configurations, and setups for building the project. +Instructions for building GeneralsGameCode and configuring its build system. -## Build Configurations Overview +## Available build guides -Before diving into the build guides, it's important to understand the different build configurations used in the -project. These configurations dictate how the project is built, whether for debugging, profiling or release. +Both `vc6` and `win32` produce 32-bit Windows builds. `vc6` uses the original Visual C++ 6 toolchain for +retail-compatible Release builds, while `win32` uses a modern Visual Studio toolchain. -- **Release:** Optimized for end-users, providing a smaller, faster executable with no debugging information. -- **Debug:** Includes debugging information, making it easier to trace and debug the code, but without optimization to - ensure ease of debugging. -- **Profile:** Used for performance profiling, with optimizations enabled and additional debugging options to collect - profiling data. +### Windows -Each configuration is designed for a different purpose, whether you're building for development, debugging, testing, or -releasing the final product. You can find more details about the build configurations in -the [Build Configurations](build_configuration) page. +| Guide | Toolchain | +| ------------------------------------------------------ | ----------- | +| [CMake and Visual Studio 6](visual_studio_6) | VC6 | +| [Build with CLion using VC6 or Win32](clion_vc6_win32) | VC6 / Win32 | +| [Visual Studio 2022 and 2026](visual_studio) | Win32 | -> **⚠️ Debug Build Requirements:** To run a debug build of the game, you need to have -> the following two files in the game directory alongside the built executable: -> -> - [`MSVCRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCRTD.DLL) -> Microsoft Visual C++ Runtime Library (Debug) -> - [`MSVCIRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCIRTD.DLL) -> Microsoft Visual C++ Internationalization Runtime Library (Debug) +### Linux -## Architectures and Toolchains +| Guide | Toolchain | +| ------------------------------------------ | --------- | +| [Build on Linux with Docker](linux_docker) | VC6 | -The project supports multiple architectures and toolchains, which is why there are various build guides tailored to -different environments. An **architecture** refers to the target platform, such as **x86** (32-bit) or **x64** (64-bit), -while a **toolchain** is the set of tools (compilers, linkers, etc.) used to build the project. Different toolchains may -support different optimizations, libraries, or debugging features that influence how the build process is conducted. +## CMake guide -> [!WARNING] -> The Wiki is under work in progress. The content is subject to change and may not be complete. -> Not all build guides are available yet, but you can contribute by adding new guides or updating existing ones. +The [Building with CMake guide](cmake_guide) covers the shared command-line workflow, common presets and +options, target selection, installation, and build-specific requirements. -## CMake Overview +## Build configurations -This [CMake Guide](cmake_guide) provides an overview of how to configure and build **Generals** and its expansion -*Zero Hour* using **CMake** via the command line. It covers the various options and flags defined in the CMake files that -control the build process, allowing you to choose different components of the game and tools to build. - -## Official Build Guides - -These are the official guides provided by **TheSuperHackers** for building the project using various toolchains and -environments. - -### **Visual Studio 6 Guides** - -1. **Using pure Visual Studio 6 (x86) (Windows)** - - A guide for building the project using only Visual Studio 6 on Windows for the x86 architecture. - [Build with pure Visual Studio 6 (x86) (Windows)](build_with_ea_msvc6) - -2. **Using Cmake & Visual Studio 6 (x86) (Windows)** - - A guide for building the project using CMake with Visual Studio 6 on Windows for the x86 architecture. - [Build with CMake & Visual Studio 6 (x86) (Windows)](build_with_msvc6) - - #### Sub-guides - - - **CLion & VC6 Toolchain** - - A guide for using CLion with the Visual Studio 6 (VC6) toolchain for building the project. - [Build with CLion & VC6 Toolchain](build_with_clion_vc6_toolchain) - - **Docker & VC6** - - A guide for setting up Docker with the Visual Studio 6 (VC6) toolchain for building the project in a - containerized environment. - [Build with Docker & VC6](build_with_msvc6_on_docker) - - **Build on Linux** - - A guide for building the project on Linux using Docker with convenience scripts. - Includes instructions for installing built executables to an existing game. - [Build on Linux](build_on_linux) - -### **Visual Studio 2022 Guides** - -1. **Using Cmake (x86) (Windows)** - - A guide for building the project using CMake with Visual Studio 2022 on Windows for the x86 architecture. - [Build with CMake (x86) (Windows)](build_with_msvc22) - -2. **Using Cmake (Linux)** - - A guide for building the project using CMake with Visual Studio 2022 on Linux. - [Build with CMake (Linux)](build_with_msvc22_linux) - -## Community Forks Build Guides - -These are the guides provided for community-supported forks of **TheSuperHackers** project. These forks are customized -versions of the original repository and may have unique build setups. - -1. **MSVC22 (x64) Generals Only (Windows)** - - A guide for building a custom fork of the project using MSVC 2022 (x64) for Windows, specifically tailored for - the "Generals Only" version. - [Build with MSVC22 (x64) Generals Only (Windows)](build_with_msvc22_x64_jmarshall2323) +The [Build Configurations Overview](build_configuration) describes the Release, Debug, and Profile configurations, the +build options, and the debug feature options that control them. diff --git a/SourceCode/Builds/build_on_linux.md b/SourceCode/Builds/build_on_linux.md deleted file mode 100644 index a0544a60..00000000 --- a/SourceCode/Builds/build_on_linux.md +++ /dev/null @@ -1,212 +0,0 @@ -# Build Command & Conquer Generals on Linux - -This guide covers building Generals and Zero Hour on Linux using Docker. The build produces Windows -executables that can run natively on Windows or under Wine on Linux. - -## Quick Start - -The repository includes convenience scripts that automate the Docker build process: - -```bash -# Clone the repository -git clone https://github.com/TheSuperHackers/GeneralsGameCode.git -cd GeneralsGameCode - -# Build using Docker (produces Windows executables) -./scripts/docker-build.sh - -# Install to your game (auto-detects Wine prefix) -./scripts/docker-install.sh --detect -``` - -## Prerequisites - -- **Docker**: Install Docker Engine for your distribution - - [Debian/Ubuntu](https://docs.docker.com/engine/install/debian/) - - [Fedora](https://docs.docker.com/engine/install/fedora/) - - [Arch Linux](https://wiki.archlinux.org/title/Docker) -- **Git**: For cloning the repository -- **Wine** (optional): For running the built executables on Linux - -### Docker Setup - -Ensure Docker is running and your user has permission: - -```bash -# Start Docker daemon -sudo systemctl start docker - -# Add your user to the docker group (logout/login required) -sudo usermod -aG docker $USER -``` - -## Build Scripts - -### docker-build.sh - -The main build script that manages the Docker-based build process. - -```bash -# Full build (both Generals and Zero Hour) -./scripts/docker-build.sh - -# Build Zero Hour only -./scripts/docker-build.sh --game zh - -# Build Generals only -./scripts/docker-build.sh --game generals - -# Build specific target -./scripts/docker-build.sh --target generalszh - -# Clean build directory first -./scripts/docker-build.sh --clean - -# Force CMake reconfiguration -./scripts/docker-build.sh --cmake - -# Enter container shell for debugging -./scripts/docker-build.sh --interactive -``` - -Build outputs are placed in `build/docker/`: - -| Directory | Contents | -| --------------------------- | ---------------------- | -| `build/docker/GeneralsMD/` | Zero Hour executables | -| `build/docker/Generals/` | Generals executables | -| `build/docker/Core/` | Shared DLLs | - -### docker-install.sh - -Installs built executables to an existing game installation. - -```bash -# Auto-detect game location (checks Wine prefixes and common paths) -./scripts/docker-install.sh --detect - -# Specify game directory manually -./scripts/docker-install.sh /path/to/game - -# Install Generals instead of Zero Hour -./scripts/docker-install.sh --game generals /path/to/game - -# Dry run (show what would be installed) -./scripts/docker-install.sh --dry-run --detect - -# Restore original files from backups -./scripts/docker-install.sh --restore /path/to/game -``` - -The script will: - -1. Backup your original executables (`.exe.backup`) -2. Copy newly built executables -3. Copy new DLLs (DebugWindow.dll, ParticleEditor.dll) -4. Preserve original mss32.dll and binkw32.dll (audio/video libraries) - -## Running the Game - -After building and installing, run the game with Wine: - -```bash -# Zero Hour (path depends on your installation) -wine /path/to/game/generalszh.exe - -# Or from the build directory (requires game data files) -wine build/docker/GeneralsMD/generalszh.exe -``` - -### Wine Configuration - -For best results: - -```bash -# Use 32-bit Wine prefix -WINEARCH=win32 WINEPREFIX=~/.wine-generals winecfg - -# Set Windows version to Windows XP or Windows 7 -winecfg -``` - -## Troubleshooting - -### Docker Permission Denied - -```text -Got permission denied while trying to connect to the Docker daemon -``` - -Solution: Add your user to the docker group and re-login: - -```bash -sudo usermod -aG docker $USER -# Then logout and login again -``` - -### Build Directory Not Found - -```text -Build directory not found: /path/to/GeneralsGameCode/build/docker -``` - -Solution: Run the build script first: - -```bash -./scripts/docker-build.sh -``` - -### Game Not Found - -```text -No game installation found -``` - -Solution: Specify the game directory manually: - -```bash -./scripts/docker-install.sh /path/to/your/game/installation -``` - -### Wine Errors - -If the game crashes or has graphical issues: - -1. Try different Wine versions (wine-staging often works better for games) -2. Install required dependencies: `winetricks directx9 vcrun6` -3. Use DXVK for better DirectX performance: `winetricks dxvk` - -## Manual Docker Build - -If you prefer to run the Docker commands manually instead of using the scripts: - -```bash -# Build the Docker image -docker build \ - --build-arg UID=$(id -u) \ - --build-arg GID=$(id -g) \ - resources/dockerbuild \ - -t zerohour-build - -# Run the build -docker run \ - -u $(id -u):$(id -g) \ - -v $(pwd):/build/cnc \ - --rm \ - zerohour-build - -# Enter container for debugging -docker run \ - -u $(id -u):$(id -g) \ - -v $(pwd):/build/cnc \ - --rm \ - -it \ - --entrypoint bash \ - zerohour-build -``` - -## See Also - -- [Build with VC6 on Docker](build_with_msvc6_on_docker.md) - Manual Docker setup -- [Build Configuration](build_configuration.md) - CMake presets and options -- [Build Guides](build_guides.md) - All build guides diff --git a/SourceCode/Builds/build_with_clion_vc6_toolchain.md b/SourceCode/Builds/build_with_clion_vc6_toolchain.md deleted file mode 100644 index 155272e2..00000000 --- a/SourceCode/Builds/build_with_clion_vc6_toolchain.md +++ /dev/null @@ -1,120 +0,0 @@ -# Compile Command & Conquer Generals And Zero Hour with VC6 in CLion - -This guide shows how to configure CLion to work with the Visual Studio 6.0 toolchain, maintaining -compatibility with the original compiler from the game's development era. To compile the source code for -**Command & Conquer: Generals** and **Zero Hour** using the CLion IDE, follow the steps outlined below. - -## Prerequisites - -- [Visual Studio 6.0 Portable](https://github.com/itsmattkc/MSVC600) - > See the [Visual Studio 6.0 Portable installation instructions](build_with_msvc6.md#visual-studio-60-portable) - > for setup details. -- [CLion](https://www.jetbrains.com/clion/) - -> This guide assumes the user uses the default installation -> folder for Visual Studio 6.0 Portable: `C:\Program Files (x86)\Microsoft Visual Studio\` - -## Step 1: Clone and Open the Project - -1. Clone the source code from TheSuperHackers: - - ```shell - git clone https://github.com/TheSuperHackers/GeneralsGameCode.git - ``` - - > Alternatively, you can clone the repository directly from within CLion. - -2. Open the cloned folder in **CLion**. - -## Step 2: Setting Up the Toolchain in CLion - -1. In CLion, go to **File** → **Settings** → **Build, Execution, - Deployment** → **Toolchains**. -2. Add a new **Toolchain** by clicking the **+** button. -3. Select **System** as the type (not Visual Studio). -4. Rename the toolchain to **Visual Studio 6**. -5. Next to the toolchain name, add the **environment** file by clicking the - **+** button and pointing to the following file: - - ```text - C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.BAT - ``` - - > **Warning**: Make sure to change the file extension from `.BAT` to `.bat` (lowercase) in the path to the - > environment file in the CLion toolchains window, otherwise CLion may have issues detecting the environment - > for some reason. - -6. Set the paths for the tools: - - **Build Tool**: Choose the `NMAKE.EXE` file from VC6. For example: - - ```text - C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\NMAKE.EXE - ``` - - - **C Compiler**: The `cl.exe` should be detected automatically. If not, set - it manually to: - - ```text - C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\cl.exe - ``` - - - **C++ Compiler**: The `cl.exe` will also be detected automatically. - -![CLion VC6 Toolchain Configuration](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/clionvc6toolchain.png) - -## Step 3: Configuring the CMake Profiles - -1. To configure the CMake profiles, proceed with the following steps: - - Go to **File** → **Settings** → **Build, Execution, Deployment** → **CMake**. - (should open automatically after opening the folder containing the cloned source code) - - Disable the default `Debug` profile. - - Enable `vc6` - Release build - - Enable `vc6-debug` - Debug build - - Enable `vc6-profile` - Profile build - - For detailed information about each build configuration and their specific purposes, see the [Build Configurations Overview](https://github.com/TheSuperHackers/GeneralsGameCode/wiki/build_configuration). - -## Step 4: Configuring the Installation Path - -1. In the **Run/Debug Configurations** dropdown, select the target game: `z_generals` (Zero Hour) or `g_generals` (Generals). -2. Open the same dropdown, then for the target game you just selected, click the 3 dots on the right, then **Edit...** - - > **Note:** This step must be repeated for both `z_generals` and `g_generals` targets. - - - Set **Program arguments** with your preferred command line arguments, such as `-win`, `-quickstart`, etc. - - Set **Executable** to the path of your game install plus the built executable name, for example: - - ```text - C:\Program Files (x86)\Command & Conquer Generals Zero Hour\generalszh.exe (for Zero Hour) or - C:\Program Files (x86)\Command & Conquer Generals Zero Hour\generalsv.exe (for Generals) - ``` - - This ensures that the game starts correctly after clicking the run button in CLion. - - - Set **Working directory** to the game directory. - - Check the **Run as administrator** option. - - To avoid duplicate builds, remove the **Build** step. - - In the **Before launch** section, add a new **install** step. - - Save the configuration, and you are ready to build and run the project. - -## Step 5: Compiling and Running the Project - - Click **Run** on the toolbar, or build the project and run the executable from the - game directory. - -## Running Debug Builds - -> **⚠️ Debug Build Requirements:** To run a debug build of the game, you need to have -> the following two files in the game directory alongside the built executable: -> -> - [`MSVCRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCRTD.DLL) -> Microsoft Visual C++ Runtime Library (Debug) -> - [`MSVCIRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCIRTD.DLL) -> Microsoft Visual C++ Internationalization Runtime Library (Debug) - -## Notes - -- Working with VC6 requires some adjustments, so it’s a good idea to verify - that the toolchain is working properly. -- Administrator rights may be required to run VC6 tools, so run CLion as an administrator if - needed. diff --git a/SourceCode/Builds/build_with_ea_msvc6.md b/SourceCode/Builds/build_with_ea_msvc6.md deleted file mode 100644 index 67546f64..00000000 --- a/SourceCode/Builds/build_with_ea_msvc6.md +++ /dev/null @@ -1,99 +0,0 @@ -# Build Pure Visual Studio 6 Guide - -This guide outlines the steps required to build and compile the source code for *Command & Conquer Generals* and its -expansion pack *Zero Hour*. The repository includes the source code and supports the Steam Workshop for both -games ([C&C Generals](https://steamcommunity.com/workshop/browse/?appid=2229870) -and [C&C Generals - Zero Hour](https://steamcommunity.com/workshop/browse/?appid=2732960)). - -[!WARNING]: This build guide is based on the original EA build instructions and has not been verified. - -## Dependencies - -Before starting the build process, you need to obtain or replace several libraries and tools. These are required for -successfully compiling the source code: - -- **DirectX SDK** (Version 9.0 or higher) - Expected path: `\Code\Libraries\DirectX\` - -- **STLport** (Version 4.5.3) - Expected path: `\Code\Libraries\STLport-4.5.3` - -- **3DSMax 4 SDK** - Expected path: `\Code\Libraries\Max4SDK\` - -- **NVASM** - Expected path: `\Code\Tools\NVASM\` - -- **BYTEmark** - Expected path: `\Code\Libraries\Source\Benchmark` - -- **RAD Miles Sound System SDK** - Expected path: `\Code\Libraries\Source\WWVegas\Miles6\` - -- **RAD Bink SDK** - Expected path: `\Code\GameEngineDevice\Include\VideoDevice\Bink` - -- **SafeDisk API** - Expected paths: - `\Code\GameEngine\Include\Common\SafeDisk` - `\Code\Tools\Launcher\SafeDisk\` - -- **Miles Sound System "Asimp3"** - Expected path: `\Code\Libraries\WPAudio\Asimp3` - -- **GameSpy SDK** - Expected path: `\Code\Libraries\Source\GameSpy\` - -- **ZLib** (Version 1.1.4) - Expected path: `\Code\Libraries\Source\Compression\ZLib\` - -- **LZH-Light** (Version 1.0) - Expected paths: - `\Code\Libraries\Source\Compression\LZHCompress\CompLibSource` - `\Code\Libraries\Source\Compression\LZHCompress\CompLibHeader` - -Ensure all dependencies are correctly set up before continuing. - -## Compiling (Win32 Only) - -**Important:** You must own the game to use the compiled binaries. The *Command & Conquer Ultimate Collection* is -available for purchase on -the [EA App](https://www.ea.com/en-gb/games/command-and-conquer/command-and-conquer-the-ultimate-collection/buy/pc) -or [Steam](https://store.steampowered.com/bundle/39394/Command__Conquer_The_Ultimate_Collection/). - -### Quick Build (Using Microsoft Visual Studio 6.0) - -1. Open the project by loading `rts.dsw` in **Microsoft Visual Studio C++ 6.0** (SP6 recommended for binary matching - with Generals Patch 1.08 and Zero Hour Patch 1.04). -2. Go to **Build -> Batch Build** in the menu. -3. Click the **Rebuild All** button to build all configurations. - -This is the simplest way to compile the game. - -### Modern Visual Studio (2015 and Newer) - -If you want to compile using a more recent version of Visual Studio, follow these steps: - -1. Open `rts.dsw` in **Microsoft Visual Studio .NET 2003**. -2. A new project and solution file will be created. -3. Open the newly created project in **Visual Studio 2015 or newer**. - -**Note:** Modern versions of Visual Studio require significant changes to the codebase, especially for Win64 -compilation, due to stricter C++ standards. You will need to make extensive modifications to ensure compatibility. - -### After Building - -Once the build is complete, the compiled binaries will be located in the `/Run/` folder inside each game’s root -directory. - -## Known Issues - -- **UAC Elevation Requirement:** Windows enforces UAC Elevation for executables with "version", "update", or "install" - in their filenames. This affects the “versionUpdate” and “buildVersionUpdate” projects. - - To resolve this, **rename the output binary** to avoid including these words. - -## STLport Compilation Issues - -To compile with STLport, you will need to apply a patch. The patch file `stlport.diff` is provided in the repository. -Make sure you are using **STLport 4.5.3** before applying the patch. diff --git a/SourceCode/Builds/build_with_msvc22.md b/SourceCode/Builds/build_with_msvc22.md deleted file mode 100644 index c52f16b8..00000000 --- a/SourceCode/Builds/build_with_msvc22.md +++ /dev/null @@ -1,167 +0,0 @@ -# Building and Compiling C&C Generals & Zero Hour on Visual Studio 2022 - -This guide will walk you through the process of basic setup and compilation of the C&C Generals and Zero Hour source -code using Visual Studio 2022. -For build using solutions and more advanced build configurations, see below. - -- [Prerequisites](#prerequisites) -- [Build through Visual Studio 2022](#build-through-visual-studio-2022) -- [Build through CMake target view](#build-through-cmake-target-view) -- [Build using command line](#build-using-command-line) -- [Build using solutions](#build-with-solutions) -- [Build with VCPKG](#build-with-vcpkg) -- [Troubleshooting](#troubleshooting) - -## Prerequisites - -1. **Visual Studio 2022** - -- Ensure that the necessary C++ development components, **including MFC**, are installed. -- For _vcpkg_ builds, you also must have **vcpkg** installed, which you can find under individual components. - ->[!NOTE] -> You must have the MFC components installed to compile the source code. You can find it in Visual Studio Installer. -> -> ![image](https://github.com/user-attachments/assets/cdabd4d9-f291-4833-8a63-704654a43780) - - -2. **Obtain the Source Code** - - Clone or download the source code - repository: [TheSuperHackers - GeneralsGameCode](https://github.com/TheSuperHackers/GeneralsGameCode.git). - ---- - -## Build through Visual Studio 2022 - -### 1. Prepare the project - -- Open the cloned folder in Visual Studio 2022. -- Wait for Visual Studio to generate the necessary CMake files. - -### 2. Build the Project - -- Select the appropriate build configuration: - - `Build Windows 32bit Release` for a release build. - - `Build Windows 32bit Debug` for a debug build. - - `Build Windows 32bit Profile` for a profile build. - - `Build Windows 32bit VCPKG Release` for a release build with the VCPKG package manager. - - `Build Windows 32bit VCPKG Debug` for a debug build with the VCPKG package manager. - - `Build Windows 32bit VCPKG Profile` for a profile build with the VCPKG package manager. - -![Build options](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/buildoptions.jpg) - ->[!TIP] -> For more information on the different build configurations, see the [Build Configurations](build_configurations.md) -page. - -- Select the target you want to build: - - `generalsv.exe` to build the base Generals. - - `generalszh.exe` to build Zero Hour. - -![image](https://github.com/user-attachments/assets/37d59b79-77fc-4797-bbab-be385dd654da) - -- Build the project by clicking on the `Build` menu and selecting `Build`. -- The compiled executable will be placed in the build folder. Example: `build/win32-debug/GeneralsMD/Debug` -- Install the game executable in the game directory by clicking on the `Install` in `Build` menu. This will copy the - executable to the retail game directory. - ---- - -## Build through CMake target view - -- In the Solution Explorer, click on 'switch view' and select 'CMake Targets View'. -- Expand the 'Genzh' project and right-click on the target you want to build. -- Select 'Build' to compile the target. - -![image](https://github.com/user-attachments/assets/adb296b6-ae05-4a23-9aa7-2a9c56b9e8e9) - ---- - -## Build using command line - -You need to install [CMake](https://cmake.org/download/) and [Ninja](https://github.com/ninja-build/ninja/releases) -to build the project from the command line. - -- In the developer command prompt, open the settings to add the x86 environment terminal. -- In the pop-up window, click on the 'Add' and set the following: (assuming default installation path) - - Name: `x86 Native Tools Command Prompt` - - Shell Location: `C:\Windows\System32\cmd.exe` - - Arguments: `/k "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"` -- Now you can open the new terminal from the terminal dropdown list. - ->[!Tip] -> Alternatively, you can skip the terminal setup and simply open the "x86 Native Tools Command Prompt for -> VS 2022" from the Start menu. Once opened, navigate to the project directory in the terminal and proceed -> to run the commands below. - -- #### 1. **Release Build** - - - **Choose the build configuration:** - - `cmake --workflow --preset win32` for Release build. - - - **Install the game executable in the game directory (assuming the build was successful):** - - `cmake --install build/win32 --config Release` - -- #### 2. **Development and Debug Builds** - - - **Choose the build configuration:** - - `cmake --workflow --preset win32-debug` for Debug build. - - `cmake --workflow --preset win32-profile` for Profile build. - - - **Install the game executable in the game directory (assuming the build was successful):** - - `cmake --install build/` - -- **To build a specific target:** - - Run `cmake --build build/ --target ` - - Example: `cmake --build build/win32-debug --target z_generals` - - Or: `cmake --build build/win32-profile --target g_generals` - -For more CMake options, see the [CMake Guide](cmake_guide). - ---- - -## Build with Solutions - -- Generate the Visual Studio solution with the appropriate preset (see above): -- Run `cmake --preset win32 -G "Visual Studio 17 2022" -A Win32` -- Navigate to the `build/win32` folder and open the generated solution file. -- Build the project using the Visual Studio interface. - ---- - -## Build with VCPKG - -To build configurations that make use of VCPKG you must set the environment variable `VCPKG_ROOT` to the location -where the VCPKG is found. If you have installed Visual Studio 2022 with the VCPKG component, you will most likely -find it in one of these paths: - -- `C:\Program Files\Microsoft Visual Studio\2022\Community\VC\vcpkg` -- `C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\vcpkg` -- `C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\vcpkg` - -If you use the stand-alone version of VCPKG, you need to use the folder you installed it in. - -### Set environment variable in command prompt - -You can set the environment variable in the command prompt. You will have to set it again if you (re)open the prompt: - -- `set VCPKG_ROOT=` - -### Set environment variable in Windows - -You can also permanently set the environment variable in Windows - -- Search for `edit the system environment variables` in Windows Search or Control Panel -- Choose `Environment Variables` -- Add a new user variable -- Set the variable name to `VCPKG_ROOT` -- Set the variable value to the VCPKG path. - ---- - -## Troubleshooting - -- **Missing DLLs?** Ensure that all required dependencies are installed. -- **Game not launching?** Verify that all necessary `.BIG` files are correctly placed. -- **Build errors?** Check Visual Studio settings and dependencies for any issues or delete the `build` folder and try - building again. diff --git a/SourceCode/Builds/build_with_msvc22_linux.md b/SourceCode/Builds/build_with_msvc22_linux.md deleted file mode 100644 index e443a413..00000000 --- a/SourceCode/Builds/build_with_msvc22_linux.md +++ /dev/null @@ -1 +0,0 @@ -# This page is a work in progress and is currently incomplete diff --git a/SourceCode/Builds/build_with_msvc22_x64_jmarshall2323.md b/SourceCode/Builds/build_with_msvc22_x64_jmarshall2323.md deleted file mode 100644 index 4f8143e8..00000000 --- a/SourceCode/Builds/build_with_msvc22_x64_jmarshall2323.md +++ /dev/null @@ -1,88 +0,0 @@ -# Building and Compiling C&C Generals on Visual Studio 2022 - -> [!WARNING] -> This build guide refers to a fork that is not from TheSuperHackers. It may include additional modifications, software, - and changes compared to the official TheSuperHackers version, and is included here for documentation purposes only. - -## Prerequisites - -- **Install Visual Studio 2022** - Ensure that the necessary C++ development components, including MFC, are - installed. - -- **Obtain the C&C Generals Source Code** - Clone or download the source code repository: - [jmarshall2323 VS2022 Fork](https://github.com/jmarshall2323/CnC_Generals_Zero_Hour.git). - -- **Install C&C Generals** - The game installation is required to access the necessary asset files. - -- **Download the necessary SDKs as needed** - 3ds max sdk: [3ds-max sdk](https://archive.org/details/maxsdk-4.2.0.85). - Download and extract the contents of the zip file to the folder - `/Code/Libraries/max4sdk` - -## Build Steps - -### 1. Copy Required Game Assets - -- Navigate to your C&C Generals installation directory, for example if using Steam: - - ``` text - C:\Program Files (x86)\Steam\steamapps\common\Command and Conquer Generals - ``` - -- Copy all necessary `.BIG` files into the `Run` folder of your compiled project: - - ``` text - EnglishZH.big - Generals.big - INIZH.big - SpeechZH.big - W3DZH.big - (Other required files) - ``` - -- Copy the entire `Data` folder to the `Run` folder as well. - -### 2. Open the Project in Visual Studio 2022 - -- Launch Visual Studio 2022 and open the solution file `Code/RTS.sln`. - -### 3. Set up Paths correctly - -- Add to your PATH environment variable the following folder: `\Code\Tools\NVASM` -- Load the RTS.sln Solution file in Visual Studio. -- Navigate to the max2w3d project folder in \toolchain\max2w3d -- Right-click on the project and select Properties. -- In the VC++ Directories tab, update the Additional Include Directories to the SDK Includes - Folder (ie \Code\Libraries\max4sdk\Include) -- And the same tab, update the Additional Library Directories to the - SDK Libraries Folder (ie \Code\Libraries\max4sdk\Lib) -- Navigate to **Properties** → **Debugging**. -- Set `Working Directory` to your `Run` folder. - ->[!NOTE] ->Ensure that the `Run` folder within your build directory contains all required game assets. - -### 4. Select and Compile the Required Projects - -- In the **Solution Explorer**, locate the following projects: - - `RTS` - - `WorldBuilder` -- Right-click each project and select **Build**. -- Ensure the build process completes without errors. - -### 5. Run the Game or World Builder - -- After compiling, navigate to the `Run` folder. -- Launch `RTSD.exe` or `worldbuilder.exe`. - -## Troubleshooting - -- **Missing DLLs?** Ensure that all required dependencies are installed. -- **Game not launching?** Verify that all necessary `.BIG` files are correctly - placed. -- **Build errors?** Check Visual Studio settings and dependencies for any issues. - -### Enjoy Modding and Playing C&C Generals! 🎮 diff --git a/SourceCode/Builds/build_with_msvc6.md b/SourceCode/Builds/build_with_msvc6.md deleted file mode 100644 index a74c1252..00000000 --- a/SourceCode/Builds/build_with_msvc6.md +++ /dev/null @@ -1,202 +0,0 @@ -# Compile Command & Conquer Generals And Zero Hour with VC6 - -This guide shows how to compile the source code for **Command & Conquer: Generals** and **Zero Hour**. To compile -the source code, follow the steps outlined below. This process is still in the early stages of development, and -ongoing efforts may lead to additional tools being compiled from the source code. The focus here is solely on -compiling the main executable, which can then be placed into the game directory and used to start the game with -the newly compiled binary. This process utilizes the original compiler from the game's development era to ensure -compatibility. - -## Intended Audience - -This guide is intended for software developers, starting from a beginner level. You should be able to -write programs and execute them. Familiarity with command-line interfaces and configuring environment -variables when necessary is required. - -Even if you do not know C++, you should still be able to compile the source code. However, a basic -understanding of how C++ is compiled is necessary. This includes knowing what the **compiler** and -**linker** do, as well as being able to interpret error messages and troubleshoot them effectively. - -## Prerequisites and setting up the build environment - -Download and install the following tools and software needed for compilation. - -> **ℹ️ Setup Note:** For simplicity, this guide will use the installers for Git and CMake and assumes the -user will use the default install folder for Visual Studio 6.0 Portable. - -### Visual Studio 6.0 Portable - -**Download:** [Visual Studio 6.0 Portable](https://github.com/itsmattkc/MSVC600) - -The original compiler used for game development. - -**Installation:** - -- Download the portable Visual Studio 6 as a ZIP file from GitHub -- Extract the `common` and `VC98` folders from the downloaded archive to the default install folder -- Default installation folder: `C:\Program Files (x86)\Microsoft Visual Studio\` - -> Alternatively, you can use the VC6 setup from Archive.org. - -### Git - -**Download:** [Git](https://git-scm.com/downloads) - -Required for cloning the source code repository. - -**Installation:** - -- Run the Git installer - -### CMake *(added to system path)* - -**Download:** [CMake 3.31.6](https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-windows-x86_64.msi) -or [newer](https://cmake.org/download/#latest) - -> **Note:** Not required if using IDEs like CLion or Visual Studio 2022, as these include built-in CMake support. - -**Installation:** - -- Run the installer for CMake -- Enable the option to add CMake to the system path during the setup wizard - -### Ninja *(added to system path)* - -**Download:** [Ninja](https://ninja-build.org/) - -> **Note:** Not required if using IDEs like CLion or Visual Studio 2022, as these include a bundled ninja binary. - -**Installation:** - -- Download the Ninja binary from the [Ninja releases page](https://ninja-build.org/) -- Extract the `ninja.exe` file to a folder of your choice -- Add the folder containing `ninja.exe` to your system's PATH environment variable - -## Clone - -Clone the code from TheSuperHackers: - -``` shell -git clone https://github.com/TheSuperHackers/GeneralsGameCode.git -``` - -``` shell -cd GeneralsGameCode -``` - -## Compilation - -> Use the Windows Command Prompt aka CMD (not PowerShell, Git Bash, etc.) to run the commands. -Otherwise, you will receive an error when building the source code. - -### Option 1: Activate your VS6 Compiler Environment - -> This needs to be done for each new instance of the CMD from which you wish to run build commands. - -Execute the setup build environment script. In your CMD, type this (assuming the default installation path): - -``` shell -"C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.bat" -``` - -### Option 2: Manually set your VS6 Compiler Environment - -> These steps need to be repeated every time after a reboot of your computer. - -``: Where you have installed VS6. - -``: Where you have the source code project. - -#### Path - -``` shell -C:\\VB98; -C:\\VC98\Bin; -C:\\VC98\Lib; -C:\\VC98\Include; -C:\\Common\tools; -C:\\Common\MSDev98\Bin -``` - -#### Environment Variables - -``` shell -set LIB=C:\\VC98\Lib;^ -C:\\VC98\MFC\Lib;^ -C:\\build\vc6 - -set INCLUDE=C:\\VC98\ATL\Include;^ -C:\\VC98\Include;^ -C:\\VC98\MFC\Include;^ -C:\\VC98\Include - -set CC=C:\\VC98\Bin\CL.exe -set CXX=C:\\VC98\Bin\CL.exe - -set MSVCDir=C:\\VC98 -``` - -### Build the project - -Run the following command based on the type of build you want to create: - -- For a release build: - -``` shell -cmake --workflow --preset vc6 -``` - -- For a debug build: - -``` shell -cmake --workflow --preset vc6-debug -``` - -- For a profile build: - -``` shell -cmake --workflow --preset vc6-profile -``` - -You will find a bunch of files in `build\vc6\` and a file called `generalszh.exe` or `generalsv.exe`. - -For detailed information about each build configuration and their specific purposes, see the -[Build Configurations Overview](https://github.com/TheSuperHackers/GeneralsGameCode/wiki/build_configuration). - -### Install the game executable - -Run the following command to copy the executable to the retail game directory: - -``` shell -cmake --install build\ -``` - -Alternatively, you can copy it manually. - -### Running Debug Builds - -> **⚠️ Debug Build Requirements:** To run a debug build of the game, you need to copy -> the following two files into the game directory alongside the built executable: -> -> - [`MSVCRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCRTD.DLL) -> Microsoft Visual C++ Runtime Library (Debug) -> - [`MSVCIRTD.DLL`](https://github.com/TheSuperHackers/GeneralsWiki/raw/refs/heads/main/SourceCode/Builds/files/MSVCIRTD.DLL) -> Microsoft Visual C++ Internationalization Runtime Library (Debug) - -## Troubleshooting - -### Error: "too long" - -- The compiler failed because the total path length for **lib** and **include** exceeded the limit for **VS6**. -- Your only option is to move your project and dependencies **closer to the root of your drive** or - rename folders in your project to shorter names. - -### Error: "could not find X.h file" - -- Ensure that you have correctly set up your `LIB` and `INCLUDE` environment variables. -- These variables are **essential** for linking and compiling header (`.h`) and library (`.lib`) files. - -### Error: "cmake --preset fails" - -- Delete the `build` folder and try again. -- Sometimes, CMake's **cache** gets corrupted, and you need to **start fresh**. diff --git a/SourceCode/Builds/build_with_msvc6_on_docker.md b/SourceCode/Builds/build_with_msvc6_on_docker.md deleted file mode 100644 index 1d486a7e..00000000 --- a/SourceCode/Builds/build_with_msvc6_on_docker.md +++ /dev/null @@ -1,121 +0,0 @@ -# Build Command & Conquer Zero Hour on Docker with VC6 - -Docker is a popular platform to standertize environments. -In this case docker is used to gather all the dependency's -and compile a **zerohour.exe** windows executable that you -can now run directly on windows or on wine. - -## Prerequisites - -You need to know how to execute docker commands and a basic understanding -how docker works and how to customize the dockerfile if you want to -compile your own code with it. - -## Dockerfile - -On your project folder create a file named `Dockerfile` and copy the -following content inside of it and save the file. - -```docker -FROM ubuntu:24.04 - -WORKDIR /build - -# Install utils -RUN apt update -RUN apt install wget gpg unzip git -y - -# Install wine32 -RUN dpkg --add-architecture i386 -RUN mkdir -pm755 /etc/apt/keyrings -RUN wget -O - https://dl.winehq.org/wine-builds/winehq.key | gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key - -RUN wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/oracular/winehq-oracular.sources -RUN apt update -RUN apt install --install-recommends winehq-stable -y - -WORKDIR /build/tools/ - -# Install cmake windows -RUN wget https://github.com/Kitware/CMake/releases/download/v3.31.6/cmake-3.31.6-windows-x86_64.zip -RUN unzip cmake-3.31.6-windows-x86_64.zip -d /build/tools/ -RUN mv /build/tools/cmake-3.31.6-windows-x86_64 /build/tools/cmake - -# Install git windows -RUN wget https://github.com/git-for-windows/git/releases/download/v2.49.0-rc1.windows.1/MinGit-2.49.0-rc1-64-bit.zip -RUN unzip MinGit-2.49.0-rc1-64-bit.zip -d /build/tools/ -RUN mv /build/tools/cmd /build/tools/git - -# Install Visual Studio 6 Portable -RUN wget https://github.com/itsmattkc/MSVC600/archive/refs/heads/master.zip -RUN unzip master.zip -d /build/tools -RUN mv /build/tools/MSVC600-master/ /build/tools/vs6 - -WORKDIR /build - -# Setup wine prefix -ENV WINEDEBUG=-all -ENV WINEARCH=win64 -ENV WINEPREFIX=/build/prefix64 -RUN wineboot - -# Create empty TEMP folder for linking -RUN mkdir /build/tmp -ENV TMP="Z:\\build\\tmp" -ENV TEMP="Z:\\build\\tmp" -ENV TEMPDIR="Z:\\build\\tmp" - -# Setup Visual Studio 6 Environment variables -ENV VS="Z:\\build\\tools\\vs6" -ENV MSVCDir="$VS\\vc98" -ENV WINEPATH="C:\\windows\\system32;\ -$VS\\vc98\\bin;\ -$VS\\vc98\\lib;\ -$VS\\vc98\\include;\ -$VS\\common\\Tools;\ -$VS\\common\\MSDev98\\bin" -ENV LIB="$VS\\vc98\\Lib;$VS\\vc98\\MFC\\Lib;Z:\\build\\cnc\\build\\vc6" -ENV INCLUDE="$VS\\vc98\\ATL\\INCLUDE;\ -$VS\\vc98\\INCLUDE;\ -$VS\\vc98\\MFC\\INCLUDE;\ -$VS\\vc98\\Include" -ENV CC="$VS\\vc98\\bin\\CL.exe" -ENV CXX="$VS\\vc98\\bin\\CL.exe" - -# Clone the source code -ENV GIT_VERSION_STRING="2.49.0" -RUN git clone https://github.com/TheSuperHackers/GeneralsGameCode.git -RUN mv /build/GeneralsGameCode /build/cnc - -WORKDIR /build/cnc - -# Run cmake -RUN wine /build/tools/cmake/bin/cmake.exe \ - --preset vc6 \ - -DCMAKE_SYSTEM="Windows" \ - -DCMAKE_SYSTEM_NAME="Windows" \ - -DCMAKE_SIZEOF_VOID_P=4 \ - -DCMAKE_MAKE_PROGRAM="Z:/build/tools/vs6/vc98/bin/nmake.exe" \ - -DCMAKE_C_COMPILER="Z:/build/tools/vs6/vc98/bin/cl.exe" \ - -DCMAKE_CXX_COMPILER="Z:/build/tools/vs6/vc98/bin/cl.exe" \ - -DGIT_EXECUTABLE="Z:/build/tools/git/git.exe" \ - -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ - -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ - -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ - -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \ - -DCMAKE_C_COMPILER_WORKS=1 \ - -DCMAKE_CXX_COMPILER_WORKS=1 - -WORKDIR /build/cnc/build/vc6 - -# Compile -RUN wine cmd /c "set TMP=Z:\build\tmp& set TEMP=Z:\build\tmp& Z:\build\tools\vs6\VC98\Bin\NMAKE.exe" - -# Keep the container alive -CMD tail -f /dev/null -``` - -Build the game by executing `docker build -t zerohour .` - -After the build you can run the container and use `docker cp` -or you could mount a volume to `/build` so you can directly -compile your own code and copy the binary off. diff --git a/SourceCode/Builds/clion_vc6_win32.md b/SourceCode/Builds/clion_vc6_win32.md new file mode 100644 index 00000000..a95bb5ae --- /dev/null +++ b/SourceCode/Builds/clion_vc6_win32.md @@ -0,0 +1,117 @@ +# Build with CLion using VC6 or Win32 + +This guide configures CLion for the `vc6` and `win32` CMake presets. Shared presets, options, targets, output paths, and +installation steps are documented in the [Building with CMake guide](cmake_guide). + +## Requirements + +- Windows +- [CLion](https://www.jetbrains.com/clion/) +- [Git](https://git-scm.com/downloads) +- One or both supported Visual C++ toolchains: + - [Visual C++ 6](visual_studio_6#install-visual-c-6) for `vc6` + - [Visual Studio Build Tools for C++](https://visualstudio.microsoft.com/visual-cpp-build-tools/) with the + [required components](visual_studio#requirements) for `win32` + +CLion's bundled CMake can be used. The Win32 toolchain can also use the bundled Ninja. + +## Configure the toolchains + +Open **File > Settings > Build, Execution, Deployment > Toolchains**. + +### Visual C++ 6 + +1. Add a **System** toolchain and name it exactly `Visual Studio 6`. +2. Add this environment file: + + ```text + C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.bat + ``` + + > [!WARNING] + > In CLion, ensure the environment file extension is lowercase `.bat`, not `.BAT`. The uppercase + > extension can prevent CLion from detecting the environment. + +3. Set **Build Tool** to VC6's `NMAKE.EXE`: + + ```text + C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\NMAKE.EXE + ``` + +4. CLion should detect `cl.exe` for both compilers; if it does not, select `VC98\Bin\cl.exe` manually. + +### Win32 + +Add a **Visual Studio** toolchain, select the Visual Studio Build Tools installation, and name it exactly +`Visual Studio`. Keep the bundled Ninja build tool. + +The exact names matter because `CMakePresets.json` uses them to select the correct toolchain automatically. + +## Clone and open the source + +Clone the repository: + +```batch +git clone https://github.com/TheSuperHackers/GeneralsGameCode.git +``` + +Open the cloned `GeneralsGameCode` directory in CLion. + +## Configure the CMake profiles + +After opening the project, CLion imports the profiles from `CMakePresets.json`: + +1. Open **File > Settings > Build, Execution, Deployment > CMake**. +2. Disable the default `Debug` profile. +3. Enable the profiles for either toolchain or both: + + | Build | Visual C++ 6 | Win32 | + | ------- | ------------- | --------------- | + | Release | `vc6` | `win32` | + | Debug | `vc6-debug` | `win32-debug` | + | Profile | `vc6-profile` | `win32-profile` | + +4. Wait for CMake to finish loading the selected profiles. + +> **Retail compatibility:** Only VC6 Release builds are compatible with retail multiplayer and replays. + +## Configure running + +Configure both `g_generals` and `z_generals` separately: + +1. Select the game target from the **Run/Debug Configurations** dropdown, open the dropdown again, and choose **Edit + Configurations**. +2. Set optional **Program arguments**, such as `-win` or `-quickstart`. +3. Set **Executable** to the installed game executable: + + ```text + C:\Path\To\Generals\generalsv.exe + C:\Path\To\Zero Hour\generalszh.exe + ``` + +4. Set **Working directory** to the corresponding game directory. +5. Under **Before launch**, remove the **Build** step and add the top-level `install` target instead. +6. Enable **Run as administrator** if the install target is in a protected directory such as `Program Files`. + +## Build and run + +Select a CMake profile and the `g_generals` or `z_generals` configuration, then click **Run**. The `install` step copies +the built executable into the game directory before CLion launches it. + +See [Install](cmake_guide#install) to set the game directories manually. + +## Troubleshooting + +### A preset is missing + +Confirm that CLion opened the repository root containing `CMakePresets.json`. Use **Help > Find Action > Load CMake +Presets**, or reset the CMake cache and reload the project. + +### A toolchain is not selected + +Confirm that the toolchains are named exactly `Visual Studio 6` and `Visual Studio`, then reload the CMake project. + +### The VC6 compiler is not found + +Confirm that the VC6 toolchain uses `VCVARS32.bat` as its environment file. If necessary, select `VC98\Bin\cl.exe` as +both compilers and reset the affected CMake profile. diff --git a/SourceCode/Builds/cmake_guide.md b/SourceCode/Builds/cmake_guide.md index f884467b..85b0ca73 100644 --- a/SourceCode/Builds/cmake_guide.md +++ b/SourceCode/Builds/cmake_guide.md @@ -1,241 +1,167 @@ -# **CMake Command Line Usage Guide** +# Building with CMake -This guide provides an overview of how to configure and build **Generals** and its expansion **Zero Hour** using **CMake** -via the command line. It covers the various options and flags defined in the CMake files that control the build process, -allowing you to choose different components of the game and tools to build. +CMake provides a common workflow for building GeneralsGameCode with Visual C++ 6 or a modern compiler. Run the commands +on this page from the repository root. -For more details on using **Visual Studio 2022**, **Visual Studio 6**, or **CLion**, please refer to the respective -guides. +## Requirements -> [!NOTE] -> CMake retains previous configurations. If you encounter any issues or strange behavior, it is recommended to delete -> the `build` directory and start fresh to ensure the build process uses the latest settings. - -- [Build Configuration (Preset)](#1-build-configuration-preset) -- [Selecting Game and Tools](#2-selecting-game-and-tools) -- [Building the Project](#3-building-the-project) -- [Install the Project](#4-install-the-project) -- [Define a Custom Installation Path](#5-define-a-custom-installation-path) -- [Building Specific Targets](#6-building-specific-targets) -- [Examples](#7-examples) - ---- - -## 1. **Build Configuration (Preset)** - -The **preset** defines the predefined build configuration. The available presets for this project are: +- [Git](https://git-scm.com/downloads) +- [CMake](https://cmake.org/download/) 3.25 or newer, added to `PATH` +- [Ninja](https://ninja-build.org/), added to `PATH` +- The toolchain required by your chosen preset -### For Visual Studio 2022 or Ninja - -- `win32`: Release build. -- `win32-debug`: Debug build. -- `win32-profile`: Profile build. - -### For Visual Studio 6 +> [!NOTE] +> The `PATH` requirements apply whenever you type these commands in a terminal, including an IDE's built-in +> terminal, because it runs a normal shell. They do not apply when using the IDE's CMake integration through its +> configure and build actions; in that case, the IDE can use its bundled CMake and Ninja tools directly. -- `vc6`: Release build. -- `vc6-debug`: Debug build. -- `vc6-profile`: Profile build. +For Visual C++ 6 setup, see [CMake and Visual Studio 6](visual_studio_6). -### Usage +## Build presets -```bash -cmake --preset -``` +These are the presets most contributors will use: -### Using the Default Workflow +| Preset | Toolchain | Purpose | +| --------------- | ----------------- | ------------------------------------------------------------------------- | +| `vc6` | Visual C++ 6 | Release build and the retail-compatible path | +| `vc6-debug` | Visual C++ 6 | Unoptimized development build; [runtime requirements](#vc6-debug-runtime) | +| `vc6-profile` | Visual C++ 6 | Optimized profiling build | +| `win32` | Modern Visual C++ | Release build | +| `win32-debug` | Modern Visual C++ | Unoptimized development build | +| `win32-profile` | Modern Visual C++ | Optimized profiling build | -You can simplify the build process by using the **workflow** option, which automatically selects the appropriate -configurations based on the preset and the project’s default settings. This eliminates the need to manually specify -build options. For example, to perform a release build with the default configuration, you can run: +For example, configure and build a VC6 Release build with: -```bash -cmake --workflow --preset win32 +```shell +cmake --workflow --preset vc6 ``` -After the build process is complete, you can proceed with the installation using the default settings, as outlined in -the installation section (not the custom path). To install the project, simply use: +Use this command to see every preset in the current checkout, including specialized presets not covered here: -```bash -cmake --install build/win32 --config Release +```shell +cmake --list-presets=all ``` -This will install the project to the default installation location based on the preset configuration. - ---- - -## 2. **Selecting Game and Tools** +> **Retail compatibility:** Use the `vc6` Release preset for builds compatible with retail multiplayer and replays. VC6 +> Debug builds and builds produced with modern Visual Studio toolchains are not retail-compatible. -You can specify various options to select which parts of the project to build. +### VC6 Debug runtime -### The available options are +VC6 Debug builds require these Microsoft debug runtime libraries in the same directory as the built executable: -- `DGENZH_BUILD_GENERALS`: Build the base Generals code, default is `ON`. -- `DGENZH_BUILD_GENERALS_TOOLS`: Build tools for Generals, default is `ON`. -- `DGENZH_BUILD_GENERALS_EXTRAS`: Build additional tools/tests for Generals, default is `OFF`. -- `DGENZH_BUILD_ZEROHOUR`: Build the Zero Hour code, default is `ON`. -- `DGENZH_BUILD_ZEROHOUR_TOOLS`: Build tools for Zero Hour, default is `ON`. -- `DGENZH_BUILD_ZEROHOUR_EXTRAS`: Build additional tools/tests for Zero Hour, default is `OFF`. +- `MSVCP60D.DLL` +- `MSVCRTD.DLL` -You can find the list of tools included in the targets list below. +The project and this wiki cannot distribute these files. Users must obtain them independently through legitimate means. -### Example Usage +## Configure and build -To build Zero Hour and its tools while excluding Generals: +The workflow command above configures and builds the project in one step. Replace `vc6` with another preset when needed. +To run the two steps separately: -```bash -cmake -DGENZH_BUILD_ZEROHOUR=ON -DGENZH_BUILD_GENERALS=OFF -DGENZH_BUILD_ZEROHOUR_TOOLS=ON +```shell +cmake --preset vc6 +cmake --build --preset vc6 ``` ---- - -## 3. **Building the Project** - -After configuring the project with CMake, you can proceed with the build step. To build the project in the appropriate -mode, use: - -```bash -cmake --build build/win32 -``` - -> [!NOTE] -> Replace the folder preset name as needed. +CMake stores each configuration under `build/`. -The build process will place the compiled executable files in the appropriate directories based on the configuration, -for example, `build/win32/GeneralsMD/Release` for the release build of Zero Hour. +## Select games and tools ---- +Both games and their tools are enabled by default. The common build options are: -## 4. **Install the Project** +| Option | Default | Controls | +| --------------------------- | ------- | ------------------------------- | +| `RTS_BUILD_GENERALS` | `ON` | Generals | +| `RTS_BUILD_ZEROHOUR` | `ON` | Zero Hour | +| `RTS_BUILD_CORE_TOOLS` | `ON` | Tools shared by both games | +| `RTS_BUILD_GENERALS_TOOLS` | `ON` | Generals tools | +| `RTS_BUILD_ZEROHOUR_TOOLS` | `ON` | Zero Hour tools | +| `RTS_BUILD_CORE_EXTRAS` | `OFF` | Shared extra tools and tests | +| `RTS_BUILD_GENERALS_EXTRAS` | `OFF` | Generals extra tools and tests | +| `RTS_BUILD_ZEROHOUR_EXTRAS` | `OFF` | Zero Hour extra tools and tests | -To install the built project, use: +Pass options while configuring. This example builds Zero Hour and its tools without Generals: -```bash -cmake --install build/win32 +```shell +cmake --preset vc6 -DRTS_BUILD_GENERALS=OFF -DRTS_BUILD_ZEROHOUR=ON -DRTS_BUILD_ZEROHOUR_TOOLS=ON +cmake --build --preset vc6 ``` -> [!NOTE] -> Replace the folder preset name as needed. This installs the executable project in the specified paths (see next -> section). - -> [!IMPORTANT] -> In the `win32` preset, use also `--config Release` to install the release executable, because the default installation -> path looks in the debug folder. - ---- +CMake retains these choices in the preset's build directory until it is reconfigured or removed. -## 5. **Define a Custom Installation Path** +## Build a target -> [!NOTE] -> To define a custom installation path, it must be set during the preset configuration. The installation path cannot be -> changed after the build is complete. +Common targets include: -By default, CMake installs the build executable in the retail game directory. If you want to specify a custom -installation path, use the following option: +| Target | Output | +| ----------------------------------------- | ------------------------------ | +| `g_generals` / `z_generals` | Game executable | +| `g_worldbuilder` / `z_worldbuilder` | World Builder | +| `g_guiedit` / `z_guiedit` | GUI Editor | +| `g_imagepacker` / `z_imagepacker` | Image Packer | +| `g_mapcachebuilder` / `z_mapcachebuilder` | Map Cache Builder | +| `core_debugwindow` | Shared Debug Window library | +| `core_particleeditor` | Shared Particle Editor library | -For Generals: +Build one target by adding `--target`: -```bash -cmake -DGENZH_GENERALS_INSTALL_PREFIX="/path/to/install" . +```shell +cmake --build --preset vc6 --target z_generals ``` -For the Zero Hour expansion: +List the targets available in a configured preset with: -```bash -cmake -DGENZH_ZEROHOUR_INSTALL_PREFIX="/path/to/install" . +```shell +cmake --build --preset vc6 --target help ``` ---- +Only enabled games and tools produce targets. Installing after a partial build may fail if another enabled installable +target has not been built. -## 6. **Building Specific Targets** +## Build output -> [!IMPORTANT] -> Please note that specific **targets** (such as `z_generals` or `z_worldbuilder`) will only work if the corresponding -> game source tree is enabled through the appropriate **preset** (e.g., `DGENZH_BUILD_ZEROHOUR` or -> `DGENZH_BUILD_ZEROHOUR_TOOLS`). Make sure the relevant game sources are included in the configuration before -> attempting to build the **targets**. +VC6 places the main executables at: -You can build specific targets by specifying them in the build command. The common targets are: +- `build//Generals/generalsv.exe` +- `build//GeneralsMD/generalszh.exe` -> [!TIP] -> The list below are suitable zero hour targets, to build base Generals targets, replace `z` with `g`. +The modern `win32` presets are multi-configuration builds, so their output paths also contain `Release` or `Debug`. -- `z_generals`: Build the Zero Hour code. +## Install -### Tools +On Windows, CMake tries to find EA App, CD, The First Decade, and Steam installations from the registry. Run each +installed game at least once first to ensure its registry entries exist. -- `z_debugwindow`: Build the Debug Window tool. -- `z_guiedit`: Build the GUI Editor tool. -- `z_imagepacker`: Build the Image Packer tool. -- `z_mapcachebuilder`: Build the Map Cache Builder tool. -- `z_particleeditor`: Build the Particle Editor tool. -- `z_worldbuilder`: Build the World Builder tool. - -### Usage +Install a VC6 Release build with: -```bash -cmake --build build/win32 --target z_generals +```shell +cmake --install build/vc6 ``` -Replace the folder preset name as needed. - -> [!NOTE] -> If from the beginning you build only with specific targets, the installation step will fail because the other targets -> are not built yet. To fix this, you need to build all targets or build the missing targets before installing. Or you -> can install the targets manually by copying the files to the correct directories from the build folder. - ---- - -## 7. **Examples** - -### **Build Zero Hour with Debug Configuration and Tools:** - -To build the Zero Hour code along with its tools in debug mode, use the following command: +Modern `win32` builds require the configuration name: -```bash -# Step 1: Configure the build with a preset and additional options -cmake --preset win32-debug -DGENZH_BUILD_ZEROHOUR=ON -DGENZH_BUILD_ZEROHOUR_TOOLS=ON - -# Step 2: Build the project -cmake --build build/win32-debug - -# Step 3: Install the project to the default installation path -cmake --install build/win32-debug +```shell +cmake --install build/win32 --config Release ``` - -### **Build Only World Builder Tool:** - -To build only the World Builder tool for Zero Hour, use the following command: -```bash -# Step 1: Configure the build with specific target -cmake --preset win32 --target z_worldbuilder +To use explicit game directories, set the install paths while configuring: -# Step 2: Build the project -cmake --build build/win32 - -# Step 3: Install the project to the default installation path -cmake --install build/win32 --config Release +```shell +cmake --preset vc6 -DRTS_INSTALL_PREFIX_GENERALS="C:\Games\Generals Test" -DRTS_INSTALL_PREFIX_ZEROHOUR="C:\Games\Zero Hour Test" +cmake --build --preset vc6 +cmake --install build/vc6 ``` - -### **Build Generals with Extras and Custom Installation Path:** -To build the Generals code with additional extras, configure the build for release, and then install the executable to a -custom directory, you can run the following commands in sequence: +Use `RTS_INSTALL_PREFIX_GENERALS` and `RTS_INSTALL_PREFIX_ZEROHOUR` independently when building only one game. -```bash -# Step 1: Configure the build with a preset and additional options -cmake --preset win32 -DGENZH_BUILD_GENERALS=ON -DGENZH_BUILD_GENERALS_EXTRAS=ON -DGENZH_GENERALS_INSTALL_PREFIX="/custom/install/path" +## Reset a configuration -# Step 2: Build the project -cmake --build build/win32 +CMake caches compiler, option, and installation settings. If a configuration starts behaving unexpectedly, discard that +preset's cache and configure it again: -# Step 3: Install the project to the specified custom directory with release configuration -cmake --install build/win32 --config Release +```shell +cmake --fresh --preset vc6 ``` ---- - -**Reminder:** -If you encounter issues from previous configurations, make sure to clear the `build` directory and restart the -configuration process. +Replace `vc6` with the affected preset. Other build configurations are left unchanged. diff --git a/SourceCode/Builds/files/MSVCIRTD.DLL b/SourceCode/Builds/files/MSVCIRTD.DLL deleted file mode 100644 index 1b8312e2..00000000 Binary files a/SourceCode/Builds/files/MSVCIRTD.DLL and /dev/null differ diff --git a/SourceCode/Builds/files/MSVCRTD.DLL b/SourceCode/Builds/files/MSVCRTD.DLL deleted file mode 100644 index 1eb91b8c..00000000 Binary files a/SourceCode/Builds/files/MSVCRTD.DLL and /dev/null differ diff --git a/SourceCode/Builds/files/buildoptions.jpg b/SourceCode/Builds/files/buildoptions.jpg deleted file mode 100644 index 032633e1..00000000 Binary files a/SourceCode/Builds/files/buildoptions.jpg and /dev/null differ diff --git a/SourceCode/Builds/files/clionvc6toolchain.png b/SourceCode/Builds/files/clionvc6toolchain.png deleted file mode 100644 index 6a6e1c5c..00000000 Binary files a/SourceCode/Builds/files/clionvc6toolchain.png and /dev/null differ diff --git a/SourceCode/Builds/linux_docker.md b/SourceCode/Builds/linux_docker.md new file mode 100644 index 00000000..9661d147 --- /dev/null +++ b/SourceCode/Builds/linux_docker.md @@ -0,0 +1,143 @@ +# Build on Linux with Docker + +GeneralsGameCode provides scripts that build the project in a Docker container on Linux. The container runs the Visual +C++ 6 toolchain through Wine and produces 32-bit Windows executables. + +> [!CAUTION] +> This guide has not been officially verified against the current repository scripts. Linux distributions, +> Docker installations, Wine prefixes, and game installations vary, so some setup or troubleshooting may be required. + +## Requirements + +- A Linux distribution +- [Docker](https://docs.docker.com/engine/install/) +- [Git](https://git-scm.com/downloads/linux) +- Wine or Proton if you intend to run the resulting executables on Linux +- An existing Generals and/or Zero Hour installation with the original game data + +Clone the repository and enter its directory: + +```bash +git clone https://github.com/TheSuperHackers/GeneralsGameCode.git +cd GeneralsGameCode +``` + +Confirm that Docker is running and accessible to your user: + +```bash +docker info +``` + +If Docker reports a permission error, follow Docker's +[Linux post-installation instructions](https://docs.docker.com/engine/install/linux-postinstall/). + +## Build + +Build both Generals and Zero Hour: + +```bash +./scripts/docker-build.sh +``` + +The first build creates the `zerohour-build` Docker image and downloads the toolchain, so it takes longer than later +builds. + +Common build commands include: + +| Command | Purpose | +| ----------------------------------------------- | ------------------------------------- | +| `./scripts/docker-build.sh --game zh` | Build Zero Hour and its tools | +| `./scripts/docker-build.sh --game generals` | Build Generals and its tools | +| `./scripts/docker-build.sh --target z_generals` | Build one CMake target | +| `./scripts/docker-build.sh --clean` | Remove `build/docker` before building | +| `./scripts/docker-build.sh --cmake` | Force CMake to configure again | +| `./scripts/docker-build.sh --interactive` | Open a shell in the build container | + +Run `./scripts/docker-build.sh --help` for the options supported by your current checkout. CMake target names are +documented in [Building with CMake](cmake_guide#build-a-target). + +Build output is stored under `build/docker`: + +| Directory | Contents | +| -------------------------- | --------------------- | +| `build/docker/GeneralsMD/` | Zero Hour executables | +| `build/docker/Generals/` | Generals executables | +| `build/docker/Core/` | Shared tools and DLLs | + +## Install into an existing game + +The installation script expects the game directory that contains the `Data` directory. It backs up original executables +before replacing them and preserves the game's original audio and video libraries. + +Ask the script to find a Wine, Proton, or supported Windows installation: + +```bash +./scripts/docker-install.sh --detect +``` + +Alternatively, pass the game directory explicitly: + +```bash +./scripts/docker-install.sh "/path/to/Command and Conquer Generals Zero Hour" +``` + +Other useful commands include: + +```bash +# Install a Generals build instead of Zero Hour +./scripts/docker-install.sh --game generals "/path/to/Command and Conquer Generals" + +# Show the files that would be installed without changing them +./scripts/docker-install.sh --dry-run --detect + +# Restore files from the backups created by the installation script +./scripts/docker-install.sh --restore "/path/to/Command and Conquer Generals Zero Hour" +``` + +## Run with Wine + +After installing the build, run it from the game's `Data` directory: + +```bash +cd "/path/to/Command and Conquer Generals Zero Hour/Data" +wine generalszh.exe +``` + +The correct Wine or Proton configuration depends on the game installation and Linux distribution. If the game fails to +start, first confirm that the unmodified retail executable works in the same prefix. + +## Troubleshooting + +### Docker is unavailable or permission is denied + +Run `docker info`. If the daemon is stopped, start it using the service manager for your distribution. If the daemon is +running but access is denied, follow Docker's post-installation guidance linked above. + +### The build directory or executables are missing + +Run the build script before the installation script: + +```bash +./scripts/docker-build.sh +``` + +If configuration files have changed or the cached build is invalid, retry with `--cmake`. Use `--clean` only when a +fresh `build/docker` directory is required. + +### The game installation is not detected + +Pass its root directory explicitly. The supplied directory must contain a `Data` subdirectory: + +```bash +./scripts/docker-install.sh "/path/to/game" +``` + +### The documented commands no longer match the scripts + +The scripts and container files in GeneralsGameCode are the source of truth: + +- [`docker-build.sh`](https://github.com/TheSuperHackers/GeneralsGameCode/blob/main/scripts/docker-build.sh) +- [`docker-install.sh`](https://github.com/TheSuperHackers/GeneralsGameCode/blob/main/scripts/docker-install.sh) +- [Docker build files](https://github.com/TheSuperHackers/GeneralsGameCode/tree/main/resources/dockerbuild) + +Use each script's `--help` output before relying on an option that may have changed. diff --git a/SourceCode/Builds/visual_studio.md b/SourceCode/Builds/visual_studio.md new file mode 100644 index 00000000..77ce112f --- /dev/null +++ b/SourceCode/Builds/visual_studio.md @@ -0,0 +1,109 @@ +# Visual Studio 2022 and 2026 + +This guide uses Visual Studio's built-in CMake support to build GeneralsGameCode with a modern compiler. The shared +presets, options, targets, output paths, and installation steps are documented in the +[Building with CMake guide](cmake_guide). + +Visual Studio 2022 and 2026 use the same steps. + +## Requirements + +- Windows +- [Visual Studio 2022 or 2026](https://visualstudio.microsoft.com/downloads/) +- [Git](https://git-scm.com/downloads) + +In Visual Studio Installer, select **Desktop development with C++** and enable: + +- **Windows 11 SDK (10.0.26100.x)** +- **C++ CMake tools for Windows** + +For Visual Studio 2022, also enable: + +- **MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)** +- **C++ MFC for latest v143 build tools (x86 & x64)** + +For Visual Studio 2026, enable these v143 compatibility components: + +- **MSVC v143 - VS 2022 C++ x64/x86 build tools (v14.44)** +- **C++ v14.44 (17.14) MFC for v143 build tools (x86 & x64)** + +Standalone CMake and Ninja installations are not required when building through the IDE. + +## Clone and open the source + +Clone the repository: + +```batch +git clone https://github.com/TheSuperHackers/GeneralsGameCode.git +``` + +In Visual Studio, select **File > Open > Folder** and open the cloned `GeneralsGameCode` directory. Visual Studio reads +`CMakePresets.json` and starts configuring the project. The first configure downloads several dependencies, so it +requires an internet connection. + +## Select a preset + +On the Visual Studio toolbar, select **Local Machine**, then choose matching configure and build presets: + +| Build | Configure preset | Build preset | +| ------- | --------------------- | --------------------------- | +| Release | Windows 32bit Release | Build Windows 32bit Release | +| Debug | Windows 32bit Debug | Build Windows 32bit Debug | +| Profile | Windows 32bit Profile | Build Windows 32bit Profile | + +Wait for the CMake output to report that generation finished before building. + +> **Retail compatibility:** Win32 builds are not compatible with retail multiplayer or replays. + +## Build + +Select **Build > Build All** to build every enabled target. + +To build one target, switch Solution Explorer to **CMake Targets View**, right-click a target such as `g_generals` or +`z_generals`, and select **Build**. + +Release game executables are written to: + +- `build/win32/Generals/Release/generalsv.exe` +- `build/win32/GeneralsMD/Release/generalszh.exe` + +## Install + +Run each installed game at least once so CMake can find its directory from the Windows registry. In **CMake Targets +View**, right-click the top-level `install` target and select **Build**. This builds the active configuration if needed, +then copies the enabled executables and debug symbols into the detected game directories. + +See [Install](cmake_guide#install) to set the game directories manually. Administrator permission may be +required when a game is installed under `Program Files`. + +## Run + +On the Visual Studio toolbar, open **Select Startup Item** and choose `g_generals` or `z_generals`. Select the green +**Start** button or press **F5** to build and run it with the debugger. To run without the debugger, select **Debug > +Start Without Debugging** or press **Ctrl+F5**. + +See the [Building with CMake guide](cmake_guide) for Debug and Profile output, game and tool selection, and +individual targets. + +## Troubleshooting + +### A preset is missing + +Confirm that Visual Studio opened the repository root containing `CMakePresets.json`. If needed, enable CMake Presets +under **Tools > Options > CMake > General**, close the folder, and open it again. + +### MFC headers or libraries are missing + +Open Visual Studio Installer, modify the installation, and add the MFC component matching your Visual Studio version +from the [requirements](#requirements). In Visual Studio 2026, confirm that the v143 compatibility MFC component is +enabled. + +### Configuration or dependency download fails + +Check the CMake output for the first error. Confirm that Git can access GitHub, then select **Project > Delete Cache and +Reconfigure**. + +### A path is too long + +Move the repository closer to the drive root, such as `C:\GeneralsGameCode`, then delete the CMake cache and +reconfigure. diff --git a/SourceCode/Builds/visual_studio_6.md b/SourceCode/Builds/visual_studio_6.md new file mode 100644 index 00000000..f8b36e83 --- /dev/null +++ b/SourceCode/Builds/visual_studio_6.md @@ -0,0 +1,94 @@ +# CMake and Visual Studio 6 + +This guide sets up the original Visual C++ 6 compiler for the GeneralsGameCode CMake build. The shared presets, options, +targets, output paths, installation steps, and configuration-specific requirements are documented in the +[Building with CMake guide](cmake_guide). + +## Requirements + +- Windows +- [Visual Studio 6.0 Portable](https://github.com/itsmattkc/MSVC600) +- [Git](https://git-scm.com/downloads) +- [CMake](https://cmake.org/download/) 3.25 or newer, added to `PATH` +- [Ninja](https://ninja-build.org/), added to `PATH` + +## Install Visual C++ 6 + +Download the Visual Studio 6.0 Portable archive and extract its `Common` and `VC98` directories into: + +```text +C:\Program Files (x86)\Microsoft Visual Studio +``` + +The compiler environment script should then be located at: + +```text +C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.bat +``` + +If you install it elsewhere, replace this path in the commands below. + +## Clone the source + +> [!IMPORTANT] +> Use Command Prompt (`cmd.exe`) for the terminal commands below, not PowerShell, Git Bash, or another +> shell. The VC6 environment must be activated again in every new Command Prompt instance. + +Clone the repository: + +```batch +git clone https://github.com/TheSuperHackers/GeneralsGameCode.git +cd GeneralsGameCode +``` + +## Activate the compiler + +Activate the VC6 environment: + +```batch +call "C:\Program Files (x86)\Microsoft Visual Studio\VC98\Bin\VCVARS32.bat" +``` + +Verify that the compiler, CMake, and Ninja are available: + +```batch +where cl +cl +cmake --version +ninja --version +``` + +`cl` should report Microsoft 32-bit C/C++ compiler version 12. + +## Build + +From the repository root, configure and build the VC6 Release preset: + +```batch +cmake --workflow --preset vc6 +``` + +See the [Building with CMake guide](cmake_guide) for Debug and Profile builds, game and tool selection, +individual targets, installation, and retail compatibility. + +## Troubleshooting + +### The compiler is not found + +Run `VCVARS32.bat` again in the current Command Prompt. Confirm that `where cl` resolves to the VC6 `CL.EXE`, not a +newer Visual Studio compiler. + +### A path is too long + +VC6 has much smaller path-length limits than modern compilers. Move the repository closer to the drive root, such as +`C:\GeneralsGameCode`, and configure it again. + +### A header or library is missing + +Run `VCVARS32.bat` and check that `INCLUDE` and `LIB` contain the VC6 directories. If the wrong compiler was cached, +reset the affected preset as described in the +[Building with CMake guide](cmake_guide#reset-a-configuration). + +### A VC6 Debug build does not start + +See the centralized [VC6 Debug runtime requirements](cmake_guide#vc6-debug-runtime). diff --git a/SourceCode/Builds/RunReleaseBuildsonMacOS.md b/SourceCode/Guides/RunReleaseBuildsonMacOS.md similarity index 100% rename from SourceCode/Builds/RunReleaseBuildsonMacOS.md rename to SourceCode/Guides/RunReleaseBuildsonMacOS.md diff --git a/SourceCode/_Sidebar.md b/SourceCode/_Sidebar.md index e2ddb4aa..01cbb9b9 100644 --- a/SourceCode/_Sidebar.md +++ b/SourceCode/_Sidebar.md @@ -4,6 +4,7 @@ - [How to Get Involved](how_to_involved) - [How to Contribution](https://github.com/TheSuperHackers/GeneralsGameCode/blob/main/CONTRIBUTING.md) +- [Running Generals Zero Hour on macOS](RunReleaseBuildsonMacOS) - [Replays for testing](replay_testing) - [In-Game Debug Commands](ingame_debug_commands) - [Community forks](forks) @@ -27,26 +28,16 @@ ## [Builds](build_guides) - [Build Configuration Overview](build_configuration) -- [CMake Overview](cmake_guide) +- [Building with CMake](cmake_guide) ### **TheSuperHackers Official Guides**: -- **Visual Studio 6 Guides**: - - [Using pure Visual Studio 6 (x86) (Windows)](build_with_ea_msvc6) - - [Using Cmake & Visual Studio 6 (x86) (Windows)](build_with_msvc6) - - [CLion & VC6 Toolchain](build_with_clion_vc6_toolchain) - - [Docker & VC6](build_with_msvc6_on_docker) +- **Windows**: + - [CMake and Visual Studio 6](visual_studio_6) + - [Build with CLion using VC6 or Win32](clion_vc6_win32) + - [Visual Studio 2022 and 2026](visual_studio) -- **Visual Studio 2022 Guides**: - - [Using Cmake (x86) (Windows)](build_with_msvc22) - - [Using Cmake (Linux)](build_with_msvc22_linux) - -### **Community Guides**: -- **macOS Guides**: - - [Using Heroic & Wine-CrossOver (Apple Silicon)](macos_heroic_wine_crossover.md) - - -### **Other Forks**: - - [MSVC22 (x64) Generals Only (Windows)](build_with_msvc22_x64_jmarshall2323) +- **Linux**: + - [Build on Linux with Docker](linux_docker) ## Libraries diff --git a/SourceCode/forks.md b/SourceCode/forks.md index 094e0870..9478e53c 100644 --- a/SourceCode/forks.md +++ b/SourceCode/forks.md @@ -8,7 +8,6 @@ ongoing efforts to bring new features, bug fixes, and cross-platform support to ## 1. Windows - [pure VS6 (x86)](https://github.com/droidix/CnC_Generals_Zero_Hour) @droidix -- [VS22 with CMake (x86) Generals Only](https://github.com/jmarshall2323/CnC_Generals_Zero_Hour) @icecoldduke - [VS6 with CMake (x86)](https://github.com/OmniBlade/CnC_Generals_Zero_Hour/tree/main) @OmniBlade - [VS22 with CMake (x64)](https://github.com/Igoorx/GeneralsGameCode/tree/x64) @disarray - [GeneralsOnline](https://github.com/x64-dev/GeneralsGameCode_GeneralsOnline) @x64-dev