# Build instructions (Linux + Windows cross-compile)

This repository builds on Linux natively and can cross-compile a **Win64** build from Linux using **MXE**.

## 1) Native build on Linux

### 1.1 Dependencies

You need:
- CMake + a C++ compiler toolchain
- wxWidgets **>= 3.2** (must provide `wx-config`)
- Boost (thread, filesystem)
- libcurl + OpenSSL
- Sound (Linux): OpenAL + Alure (**required**)

Optional:
- Translations: `gettext` (`msgfmt`)

**Debian/Ubuntu (example):**
```bash
sudo apt update
sudo apt install -y \
  git build-essential cmake pkg-config \
  libwxgtk3.2-dev \
  libboost-thread-dev libboost-filesystem-dev libboost-system-dev \
  libcurl4-openssl-dev libssl-dev \
  libopenal-dev libalure-dev \
  gettext
```

**Arch/CachyOS (example):**
```bash
sudo pacman -S --needed \
  git base-devel cmake pkgconf \
  wxwidgets-gtk3 boost curl openssl \
  openal alure \
  gettext
```

### 1.2 Configure + build

Release:
```bash
cmake -S . -B build-linux -DCMAKE_BUILD_TYPE=Release
cmake --build build-linux -j"$(nproc)"
```

Debug:
```bash
cmake -S . -B build-linux-debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build-linux-debug -j"$(nproc)"
```

If your distro doesn’t ship Alure packages, build and install Alure from source (sound support is required):
```bash
git clone --depth 1 https://github.com/kcat/alure.git
cmake -S alure -B alure/build -DCMAKE_BUILD_TYPE=Release
cmake --build alure/build -j"$(nproc)"
sudo cmake --install alure/build
```

Binary:
- `build-linux/src/springlobby`

## 2) Cross-compile Windows (Win64) from Linux (MXE)

This produces:
- `build-win64-static/springlobby-*-win64.zip`
- `build-msw-default/springlobby-*-win64.exe` (NSIS installer)

### 2.1 Host dependencies (Linux)

You need:
- build tools: `git`, `make`, `cmake`, `gcc/g++`, `pkg-config`
- MXE requirements: `gperf`, `intltool`, `lzip`, `python3-mako`, `ruby`
- packaging: `zip`, `unzip`, `7z`, `makensis` (NSIS)

**Debian/Ubuntu (example):**
```bash
sudo apt update
sudo apt install -y \
  git make cmake gcc g++ pkg-config \
  gperf intltool lzip python3-mako ruby \
  zip unzip p7zip-full nsis
```

**Arch/CachyOS (example):**
```bash
sudo pacman -S --needed \
  git base-devel cmake pkgconf \
  gperf intltool lzip python-mako ruby \
  zip unzip p7zip
```

NSIS on Arch may be in AUR on some setups:
```bash
paru -S --needed nsis
# or: yay -S --needed nsis
```

### 2.2 Build MXE (one-time)

From the repo root:
```bash
bash tools/mxe_create_builddir.sh
bash tools/mxe_compile.sh
```

This creates `./mxe` and builds a static toolchain target:
- `x86_64-w64-mingw32.static`

### 2.3 Build SpringLobby + ZIP + installer

Recommended (does everything):
```bash
bash tools/build-win64-static.sh
```

Manual (equivalent):
```bash
mxe/usr/bin/x86_64-w64-mingw32.static-cmake -S . -B build-win64-static \
  -DCMAKE_BUILD_TYPE=Release \
  -DSPRINGLOBBY_UPDATER=OFF \
  -DOPTION_NOTIFY=OFF \
  -DBUILD_SHARED_LIBS=OFF

cmake --build build-win64-static -j"$(nproc)" --target package

bash installer/make_installer.sh build-win64-static/springlobby-*-win64.zip
```

### 2.4 “Single EXE / no DLLs next to it”

The Win64 build is linked statically (MinGW runtime is not shipped as DLLs). To verify on Linux:
```bash
mxe/usr/bin/x86_64-w64-mingw32.static-objdump -p build-win64-static/src/springlobby.exe | grep "DLL Name"
```

You should not see MinGW runtime DLLs like `libstdc++-6.dll`, `libgcc_s_seh-1.dll`, `libwinpthread-1.dll`.

Sound on Windows does not require OpenAL/Alure: the Windows build uses `winmm` (built-in).

## 3) Notes / troubleshooting

- `cmake --build ...` **requires** a prior configure step (`cmake -S ... -B ...`). For Windows cross-compiling you must configure with the MXE CMake wrapper (`...static-cmake`), not the system `cmake`.
- If MXE prints “Missing requirement: ...”, install the missing tool(s) and re-run `bash tools/mxe_compile.sh`.
