Latest Posts


How to build Widelands with MSys2/MinGW64 on Windows

This is currently a work in progress!

Building with MSys2 only

Download and install MSys2

  1. Download MSYS2 from
  2. install to C:\msys64 (or choose an alternative path)
  3. Run C:\msys64\mingw64.exe or C:\msys64\mingw32.exe
  4. Follow the update steps (Nr. 5 on the MSYS2 Homepage). Running pacman -Syuu repeatedly and following the instructions on screen should do it.

Install the toolchain and the dependencies

  1. Install the mingw64 toolchain (or mingw32 toolchain), select to install all options:
    • for 64bit builds use: pacman -S mingw-w64-x86_64-toolchain
    • for 32bit builds use: pacman -S mingw-w64-i686-toolchain
  2. Install CMake and all dependencies :
    • for 64bit builds: pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja mingw-w64-x86_64-SDL2_ttf mingw-w64-x86_64-SDL2_mixer mingw-w64-x86_64-SDL2_image mingw-w64-x86_64-glew
    • for 32bit builds: pacman -S mingw-w64-i686-cmake mingw-w64-i686-ninja mingw-w64-i686-SDL2_ttf mingw-w64-i686-SDL2_mixer mingw-w64-i686-SDL2_image mingw-w64-i686-glew
  3. Install Git (our version control system): pacman -S git
  4. If you want to use GLbinding instead of GLEW: pacman -S mingw-w64-x86_64-glbinding / pacman -S mingw-w64-i686-glbinding

Get the Widelands sources

See Gitprimer on how to obtain the source code.

Configure the build

mkdir build
cd build

For 64bit builds:


For 32bit builds:


these CMAKE options define the following values in their order of appearance:
- use "ninja" instead of "MAKE"
- the c and c++ compilers are defined to be gcc and g++ (Don't change this)
- the build type is "Release" (switch to "Debug" for a debug build )
- GLEW is used instead of GLbinding (switch to ON for a GLbinding build)
- the executable (Widelands.exe) is linked statically with all dependencies so no .dll files are needed (this results in bigger .exe; you do need to use GLEW for this) - website tools are not built (saves time)
- AddressSanitizer (ASAN) is not used

to save time you could switch off Generation of translations with -DOPTION_BUILD_TRANSLATIONS=OFF

More CMake options

Run the build



In general it is a good idea in case of problems to have a look into the appveyor.yml file to see the latest working CMake options. (Additionally check the log of a latest successful apveyor build on for the commands)

The cmake, git etc. commands can't be found

You will need to add the tool binaries to the system path. You can do so by calling:

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

You'll need to do that on every restart of Msys2.

Error messages when linking ICU

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/graphic/text/libgraphic_text.a( undefined reference to `icu_61::UnicodeString::UnicodeString(char const*, char const*)'

When you get these, you probably have an ICU version sitting in C:/Windows/System32/ that is being found instead of the MSys2 copy. Did you start MSys2 using msys2_shell.cmd? Try running mingw64.exe / mingw32.exe instead.

Speeding up the file system

You can speed up the file system a little bit by doing the following:

  • Go to the control panel and search for "Indexing Options". Make sure that the MSys folder and your source code is not included
  • Right-click on the MSys folder and choose "Properties" -> "General" -> "Advanced" and switch off the indexing of file contents. Do the same for your source code directory.

You can still search the contents of your files afterwards from the MSys shell, using the grep command.

Error messages when linking curl/nghttp2

undefined reference to `_imp__curl_easy_perform'

Linking errors like this mean, that your curl library is not statically linked. Try using the version provided here: In the following code you need to replace the XX with the actual subversion of curl.

curl -Lo ""
mv curl-7.XX.0-win64-mingw/lib/libcurl.a C:/msys64/mingw64/lib/

Still 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:

CMake and Ninja

  • Download Ninja. Extract simply to C:\MinGW\bin.
  • Download CMAKE

Widelands source code

SDL2 source packages

Additional libraries

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.


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


  • 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)


  • icu4c-61_1 will not compile on MinGW, use icu4c-56_1 as linked above.


  • If you get lots of warnings like "undefined reference to `oggpack_write'" etc, you'll need to get and compile libvorbis


  • 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 dependencies. 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


  • 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

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. TODO this looks wrong! 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
Tagged with: Development, help