Compiling ScummVM/Windows CE

From ScummVM :: Wiki
Jump to navigation Jump to search

So you want to roll your own binary for the ScummVM Windows CE port? The first thing to ask yourself is do you really need to compile it? The official PocketScumm binaries are "good enough" for more than the average user. Also, bear in mind that the compilation procedure is seldom as simple as unpack-build and that, probably, you'll have to know your way around projects, makefiles and editing appropriately the source files.
Still reading? Good :-)
Many people are put off by the sheer volume of work which has to take place in order to get a successful build. Things are not that bad though as, hopefully, this document tries to describe. More than often you may find that once you set up you build environment right, there's only minimal work to be done to build any version of PocketScumm. Alright, ready? Let's go :-)

Get your gear together

The first thing you need to do is decide on the compiler and grab all required libraries.


Over the years, the compiler used to build ScummVM WinCE has changed several times. The following lists which version requires which compiler(s):

  • Versions before 0.9.0 use the Microsoft Embedded Visual C development environment. More specifically you can use either evc3 or evc4 for those versions. Most of the following instructions for building with VS2005 adhere to these builds as well.
  • Version 0.9.x supports two ways to compile:
  • Version 0.10.x builds with the VLC GCC cross compiler.
  • Version 0.11.x and newer use the cegcc GCC cross compiler. We try not to break builds with VS2005 but this can in no way be guaranteed as we do not longer use those tools. With some minor tweaking the code should be able to compile with VS tools too.

Why all these compiler changes? There are absolutely critical reasons for switching between them. For example, the migration from evc to VS is mandatory, as C++ templates introduced through core code evolution in the trunk of ScummVM cause the evc compilers to crash with 'Internal compiler error'. Unfortunately the migration is not completely successful as VS2005 (no service packs) introduces incorrect optimization in release builds, leading to workarounds in the source and compilation of specific files with no optimizations at all. Also, note that Visual Studio Express (which is free) does not support Windows CE (at least at the time of writing this). Further, the latest change from our semi-custom VLC GCC port to cegcc is mandated because building dlls which are required by the plugins is broken in the former. Fortunately we do not perceive any more compiler changes in the future. CEGCC is well maintained and even if it is not updated in the future (which seems unlikely) it is a darn good wince cross compiler as it is :-)


ScummVM depends on quite a few external libraries to handle content. These are:

Lossless audio compression for sound files.
Decoding of MPEG-2 video content.
Fixed point implementation of the OGG Vorbis algorithm, also for sound files.
MP3 sound files.
Handles all backend screen drawing.
Compressing/Decompressing files.

Arisme has done and excellent job in porting all these libraries to Windows CE, along the process of porting ScummVM itself.

For Microsoft toolchain builds, you can find all of them on his webpage both in source/patch form and as pre-built binaries. Usually, you don't need to rebuild these libraries so we recommend to use the binaries. To relieve you even further from the hassle, we have prepared a precompiled lib/header pack which is available here. This package contains all that is peripheral to ScummVM and is required for builds.

For GCC toolchain builds, the libraries need to be further patched in order to successfully compile. The patches are available here and are accumulated. This means that are direct patches to the original source versions of the libraries, that they include Arisme's patches and are not incremental to them. A precompiled lib/header pack is available for GCC builds as well and you can find it right here.

Please note that many of those libraries have been officially ported to WinCE after the work done by Arisme or, newer versions are available for them. We generally cannot comment on how well they will work with ScummVM. The more adventurous of you may want to give them a shot, but we find that these work well enough for our purposes.

Compiling using Microsoft tools

  • Build libraries from source

If you downloaded prebuilt libraries, you may skip this step. We will not document the process of compiling individual libraries. Generally, you should download the source and patch from Arisme's site, perform the patch and use the included project files to build.

  • Place library files in appropriate places.

You need two things: The library header files (*.h) and the actual libraries (*.lib). There's no place in particular where it would be good to put these files. Just make sure that the VS compiler's additional include directories option points additionally to the directory (-ies) where your library header files live, and the linker's additional library directories to the *.lib files directory (-ies). For ScummVM 0.9.1, the VS2005 files assume that the directories lib and libinclude are situated in backends/wince/missing.

  • Open the Project

For versions older than 0.9.1, project files can be found in directories dists/msevc3 and dists/msevc4 of the source tree. For 0.9.1 the project files are in dists/msvc8-wince. Open PocketScumm.vcw or PocketScumm.sln, whatever is applicable. In the workspace that opens you should be able to see several projects, the main one being the "scummvm" project and the others being the scummvm engines which are built as libraries.
A common problem which occurs here stems from the requirement that the project files have to be in CR/LF format, or else the tools will error out with various errors while opening them. (This unfortunately happens as tagging usually takes place on a non-Windows machine ( :-) ), plus some shortcomings of CVS. Hopefully SVN remedies this.)
Another point to note is that evc4 can "import" evc3 project files and VS2005 can import project files from both.

  • Build

Press F7 :-)
This is not a fool proof procedure. You may get from zero fatal compilation errors to several thousand. Please be patient and try to make sense of what the tool is reporting. More than often, the very first error the tool reports is the one you should attend to before re-trying the build. If you can't make heads or tails out of it, you may try asking for help in the forums, but *please* refrain from asking if you don't know what you're doing here. The developers cannot be burdened with the task of answering questions for your specific build setup; the community although may provide you with answers.

Compiling using the GCC toolchain

First, you need to download and install the cegcc cross compiler. More specifically, you need the mingw32 variety (without the posix layer emulation that is). The package also includes a working gdb debugger for debugging the applications.


Here is the procedure for building ScummVM:

  • Build libraries from source

You may skip this step if you downloaded the prebuilt library package. Download the original library source tarball (those in Arisme's site are OK). As an exception, get the Tremor snapshot from here. Download the diffs from here and patch the libraries. You need to configure and make each library, except the SDL library which sports a customly created (and lame :-) ) Makefile. Here are the typical parameters to the configure scripts:

  • FLAC:
CFLAGS="-D__stdcall= -D_WIN32_WCE=300 -I/usr/local/wince/cross-tools/include" LDFLAGS=-L/usr/local/wince/cross-tools/lib CC=arm-wince-pe-gcc ./configure --host=arm-wince-pe --target=arm-wince-pe --without-ogg --without-xmms -without-libiconv --without-id3lib
  • mad:
CFLAGS="-D__stdcall= -D_OFF_T_ -I/usr/local/wince/cross-tools/include" LDFLAGS=-L/usr/local/wince/cross-tools/lib CC=arm-wince-pe-gcc ./configure --host=arm-wince-pe --target=arm-wince-pe --disable-nls
  • mpeg2dec:
CFLAGS="-D__stdcall= -D_OFF_T_ -I/usr/local/wince/cross-tools/include" LDFLAGS=-L/usr/local/wince/cross-tools/lib CC=arm-wince-pe-gcc ./configure --host=arm-wince-pe --target=arm-wince-pe
  • Tremor:
CFLAGS="-D__stdcall= -D_OFF_T_ -I/usr/local/wince/cross-tools/include" LDFLAGS=-L/usr/local/wince/cross-tools/lib CC=arm-wince-pe-gcc ./ --host=arm-wince-pe --target=arm-wince-pe
  • libz:
CFLAGS="-D__stdcall= -D_OFF_T_ -D_WIN32_WCE -D_MSC_VER=666" CC=arm-wince-pe-gcc AR="arm-wince-pe-ar cru" RANLIB=arm-wince-pe-ranlib ./configure --libdir=/usr/local/wince/cross-tools/lib --includedir=/usr/local/wince/cross-tools/include

Try make libz.a for libz. Also DrMcCoy reported that he had to include "typedef long _off_t; typedef _off_t off_t;" into unistd.h

WARNING: These instructions have been written with the VLC GCC compiler in mind. Exact command lines may differ slightly from these shown aboe

You may also have to do some minor manual edits to the config.h files. (libmad's one springs to mind, in which you have to undefine HAVE_STDINT_H)

You just make each library after configuring. The SDL library has no configuration script - you just make

  • Place library files in appropriate places.

Take a look at the Makefile to check out where the headers and libs are expected. Currently they need to be under backends/platform/wince/libs/ in directories include and lib. Also note that the Makefile expects the libraries to have somewhat more "funky" names than their default. This has been done for compatibility reasons with the evc built libs. Just rename the libraries according to the Makefile, or edit the Makefile to match the default naming.

  • Build

cd into backends/platform/wince/, edit the Makefile to your needs (usually you don't have to do this). Finally type make dist, irrespectively whether you have enabled a plugin build or not, which invokes the required build automatically.