BuildingOnWindows.wiki
author Wuzzy
Fri, 27 Nov 2020 13:45:03 +0100
changeset 2200 b285ffef13e0
parent 2186 08ee59cebec7
child 2222 57453f1d37cf
permissions -rw-r--r--
Translations: Add TOC

#summary Instructions for building Hedgewars on Windows
#labels Phase-Implementation,Phase-Design,Phase-Support

= Building on Windows =

== Prerequisites ==
These build instructions require at least Windows 7.
First of all, figure out whether your system is a 32-bit or a 64-bit system. You can use the guide at [https://support.microsoft.com/en-us/help/15056/windows-32-64-bit-faq]. On a 64-bit system both 32-bit and 64-bit builds can be made, although 64-bit is preferred. Making a 64-bit build on a 32-bit system might be possible, but hasn't been tested.

== Required Tools ==
Choose either 32-bit or 64-bit depending on your system and which build you want to make.

  * CMake: click either *Windows win32-x86 Installer* or *Windows win64-x64 Installer*
    * Link: https://cmake.org/download/
  * Visual Studio: click *Download Visual Studio → Community 2019* (earlier version starting from Community 2015 Update 3 might also work)
    * Link: https://visualstudio.microsoft.com/
  * Vcpkg
    * Link: https://github.com/Microsoft/vcpkg
  * !FreePascal: click *Windows 32-bit*, then download *fpc-<version>-win32.exe* (for 64-bit builds also download *fpc-<version>.i386-win32.cross.x86_64-win64.exe*)
    * Link: https://www.freepascal.org/download.html
  * Mercurial: pick one (!TortoiseHg has a GUI and is more user-friendly)
    * !TortoiseHg: Chose one based on your OS version
      * Link: https://tortoisehg.bitbucket.io/
    * Command-line mercurial
      * Link: http://mercurial.selenic.com/downloads/

== Setup ==
  * Install CMake, but please *ensure* you select "Add CMake to the system PATH for all users", so you can run CMake directly from the command line.
  * Install !FreePascal and if necessary the 64-bit cross-compiler plugin (the one with `cross.x86_64-win64` in the file name).
  * Install Visual Studio, ensuring the *Workloads → Desktop development with C++* and *Language packs → English* options are selected.
  * Install Vcpkg by following the instructions under *Quick Start* section on the project page. If you don't have Git, use the *Clone or download → Download ZIP* option and extract the ZIP file. Create `VCPKG_ROOT` environment variable pointing to the directory you've cloned/extracted it to.
  * Install !TortoiseHg / Mercurial
  * Restart the computer
  * Download the Hedgewars source code:
    * Using !TortoiseHg:
      * Right-click in any folder on your computer
      * Select Tortoise HG → Clone.
      * In the _Source_ textbox, enter: https://hg.hedgewars.org/hedgewars/
      * Press "clone"
    * Using command-line Mercurial
      * Shift + Right-click in the folder where you want to download the source and select "Open Command Prompt Window Here" or "Open PowerShell window here".   
      * Type and execute (The initial clone of the repository will take a while): `hg clone https://hg.hedgewars.org/hedgewars/ trunk`
  * Navigate to the Vcpkg directory in the command line and build the necessary libraries (this will also take a while, especially for Qt). The command is:
    * For 32-bit builds: `.\vcpkg.exe install sdl2 sdl2-image sdl2-ttf sdl2-mixer[dynamic-load,libvorbis] sdl2-net physfs openssl qt5-base qt5-tools ffmpeg`
    * For 64-bit builds: `.\vcpkg.exe install sdl2:x64-windows sdl2-image:x64-windows sdl2-ttf:x64-windows sdl2-mixer[dynamic-load,libvorbis]:x64-windows sdl2-net:x64-windows physfs:x64-windows openssl:x64-windows qt5-base:x64-windows qt5-tools:x64-windows ffmpeg:x64-windows`
  * Build Hedgewars
    * From the Start menu run either "x86 Native Tools Command Prompt for VS 2019" or "x64 Native Tools Command Prompt for VS 2019" (if you want Hedgewars to install to the default location in `C:\Program Files`, run it as administrator).  
    * Navigate to `<hedgewars_root>\tools` where `<hedgewars_root>` is the directory where you cloned the repository source to.
    * Run `build_vcpkg.bat` script
  * After building, you can run Hedgewars from the installed location (default is `C:\Program Files\hedgewars\hedgewars.exe`)

 == Additional options ==
 Check the top section of `build_vcpkg.bat` to change some of the build options.