Latest Posts

Changes in BuildingWidelandsUnderWindowsNew

Editor Comment

Troubleshooting for SDL2_mixer


Revision Differences of Revision 25

# How to build Widelands with MinGW64 on Windows ¶

This is currently a work in progress! ¶

[TOC] ¶

# Download files ¶
## Nuwen's MinGW64 distro ¶

Download the main distro from [http://nuwen.net/mingw.html](http://nuwen.net/mingw.html) and the MSYS2 installer: ¶

* [mingw-13.4.exe](http://nuwen.net/files/mingw/mingw-13.4.exe) ¶
* [MSYS2](http://repo.msys2.org/distrib/x86_64/msys2-x86_64-20150916.exe) from [MSYS2.io](https://msys2.github.io) ¶

## SDL2 source packages ¶
* [SDL2](https://www.libsdl.org/release/SDL2-2.0.3.zip) ¶
* [SDL2_net](https://www.libsdl.org/projects/SDL_net/)
(For Build 19 and older)
* [SDL2_mixer](http://www.libsdl.org/projects/SDL_mixer/) ¶
* [SDL2_image](https://www.libsdl.org/projects/SDL_image/) ¶


## Additional libraries ¶
* [gzip](http://ftp.gnu.org/gnu/gzip/gzip-1.6.tar.gz) ¶
* [libiconv](http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz) ¶
* [gettext](http://ftp.gnu.org/gnu/gettext/gettext-0.19.6.tar.gz) ¶
* [freetype](http://download.savannah.gnu.org/releases/freetype/freetype-2.6.2.tar.gz) ¶
* [ICU](http://download.icu-project.org/files/icu4c/56.1/icu4c-56_1-src.zip) ¶

# Setting up and starting the environment ¶

* Use the self-extracting installer of Nuwen's and extract the distro to `C:\MinGW` ¶
* Install MSYS2 to `c:\msys2` and follow their [update steps](https://github.com/msys2/msys2/wiki/MSYS2-installation#iii-updating-packages)! ¶
* Open the distro window with `C:\MinGW\open_distro_window.bat` ¶
* In this shell change the directory with `cd c:\msys2` and call `msys2_shell.bat` or `msys2_shell.cmd` to start MSYS2, depending on your version of MSYS2. ¶
* You are now in a linux like shell, so the command syntax is a bit different than normal windows commands ¶
* Call `pacman -S diffutils` to make sure that the "cmp" and "diff" commands are available. The libraries will need those to configure themselves - you will probably get errors like "./configure: line 5988: cmp: command not found" otherwise. ¶
* Call `gcc --version`. If the reply is `bash: gcc: command not found`, you will need to add it to the path with `export PATH=${PATH}:/c/MinGW/bin`. Do this every time you start MSYS2. ¶


# Building all libraries ¶


* Extract all source packages to `c:\msys2\home\<username>\` ¶
* Build each package with `./configure --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/c/MinGW && make install` ¶
* Gzip1.6 does not compile without these [two patches](https://gist.github.com/TinoM/5692d59573269e6d8018) ¶
* Download the patch files, save them in the gzip source folder and patch with ¶
* patch -d . -p1 < gzip_mingw64.patch ¶
* patch -d . -p1 < gzip_mingw64_2.patch ¶
* Libiconv and freetype have circular dependencies, so you should compile libiconv, then freetype and then libiconv again (run `make distclean` and `./configure`) ¶
* libiconv: If you get a warning `remember to run 'libtool --finish /c/MinGW/lib'`, just run that command when the install has finished. If you don't have libtool, `pacman -S libtool` will fix that for you. ¶

### Troubleshooting ¶

#### no acceptable C compiler found in $PATH ¶

* You will need to execute `export PATH=${PATH}:/c/MinGW/bin` within MSYS2. You can run `gcc --version` to check the it's there ¶

#### libiconv ¶
* If compiling fails due to problems with the `INSTALLDIR` macro, track down the files and replace the macro with the hard-coded path, e.g. replace all instances of `const char *orig_installdir = INSTALLDIR;` with `const char *orig_installdir = "/c/MinGW";` (solution from [Chinese site](https://www.cnblogs.com/paktc/p/5997500.html)) ¶

#### icu ¶
* icu4c-61_1 will not compile on MinGW, use icu4c-56_1 as linked above.


#### SDL2_mixer ¶
* If you get lots of warnings like "undefined reference to `oggpack_write'" etc, you'll need to get and compile [libvorbis](https://xiph.org/downloads/)


# Download CMake and Ninja ¶

* Download [Ninja](https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip). Extract simply to *C:\\MinGW\\bin*. ¶
* Download [CMAKE](https://cmake.org/files/v3.4/cmake-3.4.1-win32-x86.zip) ¶

# Getting Widelands source code ¶

* This is described on [[ BzrPrimer ]] ¶

# Building Widelands ¶

We will build ninja in the normal distro window and not in the MSYS shell: ¶

* Open the distro window with *C:\\MinGW\\open_distro_window.bat* ¶
* Switch to the directory you'll want to build widelands in, e.g. *C:\\wl_build* ¶
* run CMAKE "cmake -G Ninja -DCMAKE_PREFIX_PATH=C:\\Mingw c:\\bzr\\widelands\\trunk". Important CMake options are documented on the [BuildingWidelands](https://wl.widelands.org/wiki/Building%20Widelands/#cmake-options) page. ¶
* Just call "ninja" to build now