Donation

Help us to pay our server!
(: Consider a donation :)



Social Media

  • Facebook
  • Google+

Latest Posts

BuildingWidelandsUnderWindowsNew

How to build Widelands with MinGW64 on Windows

This is currently a work in progress!

Download files

Nuwen's MinGW64 distro

Download the main distro from http://nuwen.net/mingw.html and the MSYS2 installer:

SDL2 source packages

Additional libraries

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

Download CMake and Ninja

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

Getting Widelands source code

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 page.
  • For building with GLEW, add the CMake option -DOPTION_USE_GLBINDING=OFF
  • Just call "ninja" to build now