Tutorial 0: Getting Started (Linux using Wine)

Requirements

Before you begin, install the following:

  • wine

    For example, on ARCH Linux use: pacman -S wine.

  • CMake 3.24 or later

    Also make sure to install cmake from here or here and install it using wine, i.e., run wine cmd from a bash prompt and from within that prompt run the cmake .msi file. Exit and launch a new wine cmd to have cmake in your PATH.

  • Stronghold Crusader 1.41 (Latin version)

    The Steam release is the easiest version to obtain. Make sure the game installation uses a Latin-language version such as English or German. Copy all binaries such as .dll and .exe to a directory named _original in the repository root.

  • Python 3

    You need this in Linux, it is not recommended in wine (Windows environment).

  • clang-format 22 or later

    In (arch) linux use:

    pipx install clang-format
    

    Other linux distributions may have its own method for installing using pip.

    Ensure clang-format is in the $PATH by running pipx ensurepath. Exit and launch a new bash shell to have clang-format in your PATH.

  • An IDE with CMake support (recommended)

    This section was written for Windows not Linux. It might not apply for Linux.

    The repository is optimized for Visual Studio Code with the Microsoft C/C++ Extension Pack.

    To automatically format and style new C++ files, install the clang-format Extension Pack.


Setup

1. Clone the repository

Clone the repository with submodules included:

git clone --recursive https://github.com/sourcehold/OpenSHC.git

Then enter the project directory:

cd OpenSHC

The --recursive flag is required because the repository depends on submodules, including the compiler.

Applying Linux specific patches

Apply the custom mt.exe and other patches:

cp -r MSVC1400-SP1/patches/ MSVC1400-SP1/

Without this patch, mt.exe may crash even though the compilation finishes fine.



3. Set up the Python environment for binary comparison

To set up the binary comparison tools, run:

python -m venv --prompt reccmp reccmp/dll/.venv
source reccmp/dll/.venv/bin/activate
python -m pip install -r reccmp/dll/requirements.txt

Exit and launch a new bash shell to have reccmp-reccmp in your PATH.

In the future, if you want to setup comparison of the reimplemented executable refer to reccmp/exe


Verifying the Setup

If both commands complete successfully, your development environment is ready and you can start working on OpenSHC.

1. Build the project

From the OpenSHC directory, run in a wine cmd prompt (wine cmd):

build.bat RelWithDebInfo OpenSHC.dll

2. Run binary comparison

This verifies byte-level accuracy between the reimplementation and the original binary (run from Linux bash not Wine, assuming you are in the right environment: source reccmp/dll/.venv/bin/activate):

pushd reccmp/dll/ # or use cd if you plan on staying in that directory
reccmp-reccmp --target STRONGHOLDCRUSADER
popd # or stay in this directory

Tip: use reccmp/dll/run reccmp-reccmp --target STRONGHOLDCRUSADER --verbose <hex address of function> to investigate code byte mismatches.