Building Legacy Widelands Under Windows
This article is outdated
It only applies to Widelands Build 18 and older.
For current trunk have a look at BuildingWidelandsUnderWindowsNew
Building widelands under Windows (MinGW)
This page is about building widelands for win32-systems (Like MS Windows XP or MS Windows 2k, ReactOS, etc). It describes, what you have to do, to get widelands compile under MinGW.
- This article is outdated
- It only applies to Widelands Build 18 and older.
- Building widelands under Windows (MinGW)
- General preparation
- Installing MinGW
- Installing MSYS
- Installing Lua
- Installing Python (only needed to generate the locales)
- Installing the needed libraries
- Compiling Widelands
- Running the code
- Building widelands under Windows (MinGW)
This little guide assumes that you have an archiver capable of handling file formats that are a bit uncommon in the windows world (like bzip2, gzip, or even lzma). A good, free and open choice would be 7-zip, in case you have none or are in doubt. You can download it here: http://www.7-zip.org/
Note: Strange for the average windows user is the use of a tarball (.tar). Some compression programs (like gzip) are file-to-file compressors and not archivers. That means that they can compress a single file only. To compress multiple files these need to be stuffed together in one file first. This is where usually a tarball is used. If you unpack any .tar.xxx file with 7-zip (and many other archivers), it will first only decompress the tarball which must then be unpacked, too!
Also mind that in the unix world directories are separated with a slash ("/") instead of a backslash ("\") as on windows. So paths look like adresses that you use in your browser.
MinGW is an minimal, unix-like environment, for building programs with gcc under Windows-systems. For installing a complete new mingw follow the instructions below. Latest MinGW-get installer mingw-get-inst-20101030.exe works well, but older MinGW versions need some additional steps.
In the installer pick options
- C++ compiler
- MSYS Basic System or MinGW Developer Toolkit
Instructions for older MinGW versions
!MingW version up to at least 5.1.6 version use an older gcc version which causes trouble and a missing make you have to download a TDM-GCC version, which you can download bundled with MinGW at
During the installation, the default settings are good (that is, you need the C and C++ compiler, and the gcc-make, you can install additional componenets if you need them).
(Or if you prefer the more complicated way, you can download MinGW separately, and then just the TDM compiler. For this, first you can find MinGW here:
In the installation of MinGW, the setup will ask you, which packages you want to be installed. The best would be, if you use the "current"-packages. The following packages are needed for widelands-compile:
- MinGW base tools
an then get these
- make-3.81-MSYS-1.0.11-2.tar.bz2 and extract them into <yourmingwfolder> overwriting any files.)</yourmingwfolder>
Msys is a program offering you a bash-like (the bash is the unix command shell) environment under windows. If you used new Mingw-get installer and picked MSYS option, then it's already installed.
- You can get the latest Msys here MSYS latest files but the current builds are a bit more complicated to set up and an older version will suffice to compile widelands (get version 1.0.11 here).
Install MSYS (e.g. D:\MinGW\msys). After the installation a command prompt will pop up and ask you some questions:
Do you wish to continue with the post install? -> press y Do you have MinGW installed? -> press y Where is your MinGW installation? -> d:/mingw (note the slash instead of usual backslash and all lower case!).
If you plan to do more with the source code than just compiling your own builds, you may also want to get the GNU Debugger. However you will not need it in just compiling widelands. Mingw-get based installation can get this with running "mingw-get install gdb" or pick MinGW Developer toolkit in the installer.
Download the Lua installer for Windows.
Run the installer.
Installing Python (only needed to generate the locales)
If you want to compile the locales, download python
python-2.5.2.msi and install it (e.g. to C:\Python). To use it you will need to set one system environment variable. To do this in Windows XP, just right-click
My Computer > Properties > Advanced > Environment Variables > System Variables > Path > Edit
Directories in the path variable are separated by semicolons, so append ;C:\Python to your current path. Do not under any circumstances erase any part of your path variable if you don't know what you are doing! Then click OK and you are done with setting up python.
Note: If you installed python to its default directory, you of course have to append ;C:\Python25 to your path instead!
Installing the needed libraries
After installing MinGW and MSYS, you need to install all libraries and programs, which are needed by widelands. You can wither use combination of prebuilt and compiled libraries as presented in subsequent paragraphs or build all dependency libraries from source using source bundle in lp:~jarih/+junk/wl-3rdparty-src.
Here is a list of the needed files:
First let's get the precompiled packages
- SDL_image: homepage (Look for the binary win32 devel version), current version is: SDL_image-devel-1.2.10-VC.zip
- SDL_mixer: homepage (Look for the binary win32 devel version), current version is: SDL_mixer-devel-1.2.12-VC.zip
- SDL_net: homepage (Look for the binary win32 devel version), current version is: SDL_net-devel-1.2.7-VC8.zip
- SDL_ttf: homepage (Look for the binary win32 devel version), current version is: SDL_ttf-devel-2.0.10-VC.zip
Download and unpack them into a temporary folder and move over the directories include and lib from each package into <yourmingwfolder> (e.g. you extracted SDL_image-devel-1.2.6-VC8.zip into D:\tmp. Now go into D:\tmp\SDL_image-1.2.6 and move over the two directories into <yourmingwfolder>).</yourmingwfolder></yourmingwfolder>
Ether you download and use the boost header files or you compile boost yourself. Using only the header files will disable unit test.
- The boost header files can be downloaded here: Boost 1.48.0. Unpack and copy the "boost" folder to <yourmingwfolder>\include.</yourmingwfolder>
- Instructions how to build boost on MinGW can be found here
Download and unpack them into a temporary folder. You will have subdirectories called bin, lib, share and include. Move those subdirectories over into <yourmingwfolder>. Remember that you might have to unpack these archives "twice": first the .lzma file and then the tarball.</yourmingwfolder>
Download, unpack and move these like you did with the gettext packages just aboce.
Finally download and extract these archives directly into <yourmingwfolder>.</yourmingwfolder>
Packages needed to compile
We recommend creating <yourmingwfolder>/src for these packages</yourmingwfolder>
libpng-1.2.29.tar.bz2 Download and unzip it to <yourmingwfolder>/src. Now run MYSYS and change to its folder (you do so by executing the command cd /mingw/src/libpng-1.2.29/ - change the directories if your mingw is not resident in c:\mingw. Note that there is a space between cd and /mingw!). Now execute the following commands:</yourmingwfolder>
You can leave MYSYS with the command logout.
SDL-devel-1.2.13-mingw32.tar.gz download and unzip it to <yourmingwfolder>/src, go with msys in its folder and run</yourmingwfolder>
make install-sdl prefix=/mingw
Note: SDL-1.2.14 contains a bug that prevents mouse to work when alt-tabbing from fullscreen mode. Bug is fixed in latest 1.2 development version.
SDL_gfx-2.0.19.tar.gz download and unzip it to <yourmingwfolder>/src, go with msys in its folder and run</yourmingwfolder>
make -f Makefile.mingw prefix=/mingw
make -f Makefile.mingw prefix=/mingw install
- Download the Binaries and unzip.
- Follow the build instructions in the Readme.
extra header file
- Download wspiapi.h from http://www.koders.com/c/fid275FEAF57FA3E640A9425FB3A46D988E1F72B61D.aspx and move it to /mingw/include
You have to do this, if you want to build an .exe-file that runs on windows versions older than windows XP.
Building dependency libraries from 3rdparty source bundle
The source bundle is ported to be compatible with Visual Studio 2008 and therefore some libraries use old versions and may contain minor modifications. Minimal set of Boost headers is included in boost_minimal directory, but is not installed automatically. Either install full boost following the boost related section above, or copy boost directory from boost_minimal to include directory on /usr/local/include. This means that unit tests wont build, but you'll still be able to build the game. Extra header file wspiapi.h is not included in bundle, use the above instructions if you need it.
Build script requires that
- CMake (http://www.cmake.org/cmake/resources/software.html) is installed and
- Get sources running : "bzr branch lp:~jarih/+junk/wl-3rdparty-src"
- MSYS environment has automake, autoconf and libtool. These can be installed with mingw-get based installation running: "mingw-get install automake autoconf libtool" inside MSYS environment.
- Launch MSYS environment and enter source directory.
- Launch build script "./buildmingw.sh"
The build script is quite simple, and won't much report errors. If everything succeeds, all libraries and tools are built and installed to MSYS environment in /usr/local.
Download the source
Check out the widelands source code (see DownloadPage for infos on the SVNROOT and all).
Compiling the source using Makefiles
Before building, go to <widelands-directory>/build/win32/mingw/ and rename and/or copy build_info.cc.default to build_info.cc</widelands-directory>
Start msys and go to <widelands-directory>/build/win32/mingw/ and run</widelands-directory>
To generate the locales, go to <widelands-directory>/build/win32 and run</widelands-directory>
Compiling the source using CMake build chain and libraries from 3rdparty bundle
CMake based build chain works directly within MSYS environment. CMake must be in PATH so that it's seen by MSYS command prompt.
Launch MSYS environment and navigate to root source folder. When libraries are installed under /usr/local, additional parameters are needed for CMake. So for the first time, cmake must be called manually. You might need to adjust some paths from the example below, depending on where you installed and built everything. Later it's enough to use ./compile.sh.
- cd build
- cmake -G "MSYS Makefiles" -DCMAKE_PREFIX_PATH=/usr/local/ -DCMAKE_INCLUDE_PATH=/usr/local/include/SDL/ -DCMAKE_BUILD_TYPE=Release ../ -DBOOST_INCLUDE_DIR=/usr/local/include/boost/ -SDLGFX_INCLUDE_DIR=/mingw/include/SDL/ -DSDLGFX_LIBRARY:FILEPATH="/mingw/lib/libSDL_gfx.dll.a" -DSDLGFX_INCLUDE_DIR:PATH="/mingw/include/SDL" -DGLEW_LIBRARY:FILEPATH="<yourmingwfolder>src//glew-1.10.0/lib/libglew32.dll.a"</yourmingwfolder>
- cd ..
If you don't have compiled boost libraries, widelands executable works with just boost headers. Unit testing requires compiled boost unit test framework libararies. Release build omits the unit tests, but debug version includes them. Pass -DWL_UNIT_TESTS=FALSE option to cmake to disable unit tests also in debug mode.
When working inside MSYS environment DLL dependencies are already in path. To launch the widelands directly from windows, copy needed dll's alongside widelands.exe. Full dependencies (9.1.2011) when mingw-get installer is used and 3rdparty libs are build from bundle:
- from /usr/local/bin: SDL.dll SDL_image.dll SDL_mixer.dll SDL_net.dll SDL_ttf.dll libSDL_gfx-13.dll libcharset-1.dll libiconv-2.dll libintl-3.dll libjpeg-8.dll libogg-0.dll libpng14.dll libvorbis-0.dll libvorbisenc-2.dll libvorbisfile-3.dll lua51.dll zlib1.dll
- from /mingw/bin/: libgcc_s_dw2-1.dll libpthread-2.dll libstdc++-6.dll
Running the code
There are a few more things you need to do before you can run the code. You will need to copy the needed DLL files into your exe's path, and you need wideland's data and locale dirs.
Copying the DLL files
If you have compiled widelands, you must copy all needed dll-files in widelands-folder. Without these files widelands won't work. Normally the dll-files of these packages can be found in
You need the following dlls-files (as at October 2013):
glew32.dll libfreetype-6.dll libgcc_s_dw2-1.dll libiconv-2.dll libintl-8.dll libjpeg-8.dll libogg-0.dll libpng15-15.dll libSDL_gfx-13.dll libstdc++-6.dll libvorbis-0.dll libvorbisfile-3.dll libz-1.dll SDL.dll SDL_image.dll SDL_mixer.dll SDL_net.dll SDL_ttf.dll
If you can't find them there, you can also grab them from a previously installed Widelands version. However, make sure the version of each DLL is identical to the corresponding header files you used while compiling. Otherwise, Widelands will abort with an error message.
Setting the data and locale dirs
The easiest way is to provide WIdelands with the needed data and locale files is to get a current nightly build and install it into
C:\Widelands. Change to your widelands dir in MinGW and call the program like this:
widelands.exe --datadir=/c/Widelands --localedir=/c/Widelands/locale
If there are any problems and you can't find a solution, please write on the forums or meet us on irc. Furthermore it would be good, if you could add your hints or solutions on this page, so that people, standing before the same problems can easier find a solution.