Latest Posts

Changes in BuildingWidelandsUnderWindowsNew

Editor Comment

Added instructions for Msys

Revision Differences of Revision 37

# How to build Widelands with MSys2/MinGW64 on Windows ¶

This is currently a work in progress! ¶

[TOC] ¶

# Building with MSys2 only ¶

## Download and install M
Sys2 ¶

1. **Download MSYS2** from [](,
eiher the 64 bit or the 32 bit version, depending on which type of build you want to create ¶
2. Depending on your version, **install** to `C:\msys64` or `C:\msys32` ¶
3. **Run** `C:\msys64\msys2_shell.cmd` or `C:\msys32\msys2_shell.cmd` ¶
4. Follow the [update steps]( Running `pacman -Syuu` repeatedly and following the instructions on screen should do it. ¶

## Install the toolchain and the dependencies ¶

5. Install the mingw64 **toolchain** (or mingw32 toolchain) using `pacman -S mingw-w64-x86_64-toolchain` for 64bit builds, `pacman -S mingw-w64-i686-toolchain` for 32bit builds. ¶
6. Install **CMake** and all **dependencies** : `pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-boost mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-glbinding` for 64bit builds, `pacman -S mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-boost mingw-w64-i686-SDL2_ttf mingw-w64-i686-SDL2_mixer mingw-w64-i686-SDL2_image mingw-w64-i686-glbinding` for 32bit builds. ¶
7. Install **Bazaar** (our version control system): `pacman -S bzr` ¶
8. If you want to use **GLEW** instead of glbinding: `pacman -S mingw-w64-x86_64-glew` / `pacman -S mingw-w64-i686-glew` ¶
9. On Windows 10, you will need to **downgrade Boost**. Download the boost 1.66 package and its signature file from to `C:\msys42/home/<username>`. Call `pacman -U <tar_xz_filename>`. ¶

## Configure paths ¶

`export PATH=${PATH}:/c/msys64/mingw64/bin` for 64bit builds, `export PATH=${PATH}:/c/msys64/mingw32/bin` for 32bit builds. ¶

## Get the Widelands sources ¶

~~~~ ¶
mkdir widelands ¶
cd widelands ¶
bzr init-repo . ¶
bzr branch lp:widelands trunk ¶
bzr branch trunk <my_own_branch_to_work_on> ¶
cd <my_own_branch_to_work_on> ¶
~~~~ ¶

## Configure and run the build ¶

~~~~ ¶
mkdir build ¶
cd build ¶
ninja ¶
~~~~ ¶

## Having problems? ¶

Please post any issues to the [relevant forum thread](

# Building with Nuwen's MinGW64 distro ¶

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

Download the main distro from []( and the MSYS2 installer: ¶

* [mingw-13.4.exe]( ¶
* [MSYS2]( from []( ¶

### CMake and Ninja ¶

* Download [Ninja]( Extract simply to `C:\MinGW\bin`. ¶
* Download [CMAKE]( ¶

### Widelands source code ¶

* This is described on [[ BzrPrimer ]] ¶

### SDL2 source packages ¶
* [SDL2]( ¶
* [SDL2_net]( (For Build 19 and older) ¶
* [SDL2_mixer]( ¶
* [SDL2_image]( ¶
* [SDL2_ttf]( ¶

### Additional libraries ¶
* [gzip]( ¶
* [libiconv]( ¶
* [gettext]( ¶
* [freetype]( ¶
* [ICU]( ¶
* [GLEW]( or glbinding ¶

## Set up and start 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](! ¶
* 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. ¶

## Build 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]( ¶
* 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 that 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]( ¶

### 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]( ¶

### SDL2_image ¶
* I kept getting an error "libobj name `IMG.Tpo -c -o IMG.lo IMG.lo' may not contain shell special characters." that would not go away. They provide ready-made development packages though (SDL2_image-devel-2.0.3-mingw.tar.gz (MinGW 32/64-bit)), so try grabbing one of those. I tried fixing the error by compiling the depencies. Ran into some trouble with the dependencies too and am documenting it here, just in case it will come in useful: ¶
* [libtiff]( No problems ¶
* [libjpeg]( `cannot create regular file '/c/MinGW/man/man1/cjpeg.1': No such file or directory`. Simply create the `C:\MinGW\man\man1` folder and run `make install` again ¶
* [libpng]( Get a tar distribution, or there will be no configure available. `pnglibconf.h:205:54: error: expected identifier or '(' before '-' token` - Open pnglibconf.h and delete the extra line breaks, so that every #define statement is in a single line ¶
* [zlib]( Does not use autotools, so the configure command is `./configure --static --64 --prefix=/c/MinGW`. Then `make install` as usual ¶

### Gettext ¶
* Install perl `pacman -S perl` ¶
* Compiler complains about `LOCALE_ALIAS_PATH` and `LOCALEDIR`: Replace `LOCALE_ALIAS_PATH` and `LOCALEDIR` with `"/c/MinGW/share/locale` in: ¶
* gettext-runtime/intl/dcigettext.c ¶
* gettext-runtime/intl/localealias.c ¶
* gettext-runtime/intl/os2compat.c ¶
* gettext-runtime/intl/os2compat.h ¶
* Compiler complains about `INSTALLDIR`: In `gettext-runtime/intl/relocatable.c`, delete all instances of `&& defined INSTALLDIR` and then replace `INSTALLDIR` with `"/c/MinGW/lib"` ¶
* "undefined reference to \`__imp_pthread_rwlock_unlock'" - Get the [precompiled pthreads binary]( and dump it into `C:\MinGW` ¶
* `aclocal-1.15: command not found`: Install autotools `pacman -S automake m4 autoconf` ¶
* Problems with an `sed` command: ¶
* Call `cd gettext-runtime` and compile gettext from there ¶
* The error is coming from `gettext-tools` - you can grab those from MSYS2 by copying `msgfmt.exe` and `msgmerge.exe` from `C:\msys64\mingw64\bin` to `C:\MinGW\bin` - that will be enough to make CMake happy. If you want to build `.pot` catalogs, you will also need `xgettext.exe`. ¶
* The above error looks like this: ¶
~~~~ ¶
} > math.h-t && \ ¶
mv math.h-t math.h ¶
/usr/bin/sh: -c: line 214: syntax error: unexpected end of file ¶
make[4]: *** [Makefile:4294: math.h] Error 1 ¶
~~~~ ¶

* In case you're still having trouble, you can try the [MSYS2 patches](I have found a series of patches: ¶

## Build 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]( page. ¶
* For building with GLEW, add the CMake option `-DOPTION_USE_GLBINDING=OFF` ¶
* Just call "ninja" to build now