Difference between revisions of "Compiling ScummVM/Windows CE"

From ScummVM :: Wiki
Jump to navigation Jump to search
m (→‎Compiling using the GCC toolchain: more cygwin packages)
(Early cleanup and some spell corrections)
 
(14 intermediate revisions by 3 users not shown)
Line 1: Line 1:
So you want to roll your own binary for the ScummVM [[Windows CE]] port?
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 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.
The official ScummVM for Windows CE 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 makefiles and editing appropriately the source files.
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
Still reading? Good :-)
projects, makefiles and editing appropriately the source files.<br/>
 
Still reading? Good :-)<br/>
Many people are put off by the sheer volume of work which has to take place
Many people are put off by the sheer volume of work which has to take place
in order to get a successful build.
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 ScummVM for Windows CE.
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 :-)
Alright, ready? Let's go :-)


== Get your gear together ==
== Get your gear together ==


The first thing you need to do is decide on the compiler and grab all required
=== Compilers ===
libraries.
Over the years, the compiler used to build ScummVM WinCE has changed several times. The following lists which version requires which compiler(s):


=== Compilers ===
* Versions '''before''' 0.9.0 use the Microsoft Embedded Visual C development environment. More specifically you could use either [http://www.microsoft.com/downloads/details.aspx?familyid=f663bf48-31ee-4cbe-aac5-0affd5fb27dd&displaylang=en evc3] or [http://www.microsoft.com/downloads/details.aspx?familyid=4a4ed1f4-91d3-4dbe-986e-a812984318e5&displaylang=en evc4] for those versions.
* Version 0.9.x supported two ways to compile:
** Using [http://msdn.microsoft.com/windowsmobile/downloads/tools/install/default.aspx Microsoft Visual Studio 2005], or
** Using the [http://download.videolan.org/pub/testing/wince/ Windows CE GCC cross compiler] developed by the [http://www.videolan.org/vlc/ VLC] team ('''do not''' rush to download and install this compiler. It needs to be rebuilt first. More on this [[Compiling_ScummVM/Windows_CE/Old_GCC|on this page]]).
* Version 0.10.x builds with the VLC GCC cross compiler.
* Version 0.11.x and newer use the [http://cegcc.sf.net/ cegcc] GCC cross compiler.
* Version 1.0 and newer use the [http://cegcc.sf.net/ mingw32ce] GCC cross compiler. This is only compiler being supported now. You may succeed in compiling with VS2005, but this is beyond the scope of these instructions.


Versions before 0.9.0 use the Embedded Visual C development environment.
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'.
More specifically you can use either
[http://www.microsoft.com/downloads/details.aspx?familyid=f663bf48-31ee-4cbe-aac5-0affd5fb27dd&displaylang=en evc3] or
[http://www.microsoft.com/downloads/details.aspx?familyid=4a4ed1f4-91d3-4dbe-986e-a812984318e5&displaylang=en evc4]
for those versions.
Most of the following instructions for building with VS2005 adhere to these builds as well.


For the current 0.9.0 branch and the trunk there are two ways to compile:
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.


* Using [http://msdn.microsoft.com/windowsmobile/downloads/tools/install/default.aspx Microsoft Visual Studio 2005], or
Also, note that [http://msdn.microsoft.com/vstudio/express/ Visual Studio Express] (which is free) does not support Windows CE (at least at the time of writing this).
* Using the [http://download.videolan.org/pub/testing/wince/ Windows CE GCC cross compiler] developed by the [http://www.videolan.org/vlc/ VLC] team ('''do not''' rush to download and install this compiler. It needs to be rebuilt first. More on this [[#Compiling using the GCC toolchain|later]]).


The former is used for building the 0.9.0 branch.
Further, the change from our semi-custom VLC GCC port to cegcc was mandated because building dlls which are required by the plug-ins is broken in the former.  
The migration from evc to VS is mandatory, as C++ templates introduced
through core code evolution in the trunk of ScummVM
cause the evc to 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 [http://msdn.microsoft.com/vstudio/express/ Visual Studio Express] does
not support Windows CE.


The latter method (GCC) is slated to be used for building PocketScumm, starting with the next major release (0.10.0).
Finally we have switched to mingw32ce, which does not use the Unix compatibility layer which cegcc brings along as we don't need it.
As such, the trunk currently contains only the necessary Makefile for building with GCC.
It does not contain any VS2005 project files, athough we may in the future opt to
also provide project files for it as well.


=== Libraries ===
=== Libraries ===
Line 53: Line 38:
These are:
These are:


* [http://flac.sourceforge.net/ FLAC] 1.1.0
* [http://wss.co.uk/pinknoise/tremolo/ Tremolo] 0.7
: Lossless audio compression for sound files.
: Tremolo is an ARM optimized version of the Tremor lib from [https://www.xiph.org/]. For those that don't know, the Tremor lib is an integer-only library for doing Ogg Vorbis decompression.
* [http://libmpeg2.sourceforge.net/ mpeg2dec] 0.4.0
* [https://www.underbit.com/products/mad/ mad] 0.15.1b
: Decoding of MPEG-2 video content.
* [http://www.xiph.org/vorbis/ Tremor]
: Fixed point implementation of the OGG Vorbis algorithm, also for sound files.
* [http://www.underbit.com/products/mad/ mad] 0.14.2b
: MP3 sound files.
: MP3 sound files.
* [http://www.libsdl.org/ SDL] 1.2.6
* [https://www.libsdl.org/ SDL] 1.2.6
: Handles all backend screen drawing.
: Handles all backend screen drawing.
* [http://www.zlib.net/ zlib] 1.2.1
* [https://www.zlib.net/ zlib] 1.2.5
: Compressing/Decompressing files.
: Compressing/Decompressing files.


[[user:Arisme|Arisme]] has done and excellent job in porting all these libraries to Windows CE,
[[user:Arisme|Arisme]] and [[user:Jubanka|Knakos]] have done an excellent job in porting all these libraries to Windows CE, along the process of porting ScummVM itself. Lately, this job is being done by [[user:CeRiAl|CeRiAl]].
along the process of porting ScummVM itself.
 
For Microsoft toolchain builds, you can find all of them on [http://arisme.free.fr/ports/ 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 [http://users.uoa.gr/~knakos/scummvm/libraries/vs2005_libpack.zip 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
Furthermore, the libraries need to be patched in order to successfully compile.
to successfully compile.
The patches are available [http://pocketinsanity.org/scummvm/libraries/ here] and are '''accumulated'''.
The patches are available [http://users.uoa.gr/~knakos/scummvm/libraries/ here] and are '''accumulated'''.
This means that are direct patches to the original source versions of the libraries,
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.
that they include Arisme's, Knakos' and CeRiAl's patches and are ''not'' incremental to them.
A precompiled lib/header pack is available for GCC builds as well and
A precompiled lib/header pack is available as well and
you can find it right [http://users.uoa.gr/~knakos/scummvm/libraries/wince-gcc-libs.tar.bz2 here].
you can find it right [http://pocketinsanity.org/scummvm/libraries/release-1-5-0/wince-gcc-libs.tar.bz2 here].


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


== Compiling using Microsoft tools ==
== Compiling using the mingw32ce GCC toolchain ==
 
* 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 <tt>lib</tt>
and <tt>libinclude</tt> are situated in <tt>backends/wince/missing</tt>.
 
* Open the Project
For versions older than 0.9.1, project files can be found in directories
<tt>dists/msevc3</tt> and <tt>dists/msevc4</tt> of the source tree.
For 0.9.1 the project files are in <tt>dists/msvc8-wince</tt>.
Open <tt>PocketScumm.vcw</tt> or <tt>PocketScumm.sln</tt>, 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.<br/>
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.)<br/>
Another point to note is that evc4 can "import" evc3 project files
and VS2005 can import project files from both.


* Build
First, you need to download and install the [http://cegcc.sf.net/ mingw32ce] cross compiler. More specifically, you need the mingw32ce variety (without the posix layer emulation that is). You may optionally also download a working gdb debugger there for debugging the applications. Version 0.59.1 is the recommended version, your mileage may vary with other versions. It's also recommended, though not mandatory, to install the toolchain to /opt/mingw32ce (in the following example we use this directory).
Press F7 :-)<br/>
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 usual, 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 [http://forums.scummvm.org/viewforum.php?f=6 forums], but '''*please*''' refrain yourself from
asking if you don't know what you're doing here.
The developers cannot be burdened by the task of answering questions
for your specific build setup.
 
 
== Compiling using the GCC toolchain ==
 
The VLC port of GCC requires some prep work before it's ready for action.
There are two major problems with it:
It does not honor the <tt>#pragma pack()</tt> directive and there is a store layout bug for packed structs.
Hence, it needs to be rebuilt.
As a welcome aside though, the procedure described in the following subsections can be applied to linux
or cygwin based environment.
This means that the cross compiler can be installed onto a Windows ([http://www.cygwin.org Cygwin])
machine as well.
 
''It has been reported that the packages needed for Cygwin are: gcc, make, sed, bison, flex, texinfo, patch, cvs, gettext, gettext-devel, perl. Also some CR/LF conversion may be needed by utilities such as dos2unix and unix2dos.''
 
=== Cross compiler ===
 
The build process is carried out in two steps, first the binutils and then the gcc cross compiler.
Begin by designating a directory where all source downloads and build will take place.
 
(''Note:'' the patches by the VLC guys target specific GCC/binutils versions.
We'll rebuild those exact versions as they are good enough for the time being.)
 
==== Binutils ====
 
Checkout the binutils source, as described in the [http://www.gnu.org/software/binutils/ GNU Binutils]
page but designating a revision date as well:
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
{enter "anoncvs" as the password}
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co -D 20050514 binutils
CD into the root of the source tree and patch with the three
[http://download.videolan.org/pub/testing/wince/patches/ VLC binutils patches] (may patch with a little fuzz).
Configure the build:
./configure --target=arm-wince-pe --prefix=PREFIX_TO_CROSS_COMPILER
(PREFIX_TO_CROSS_COMPILER is the path where the cross compiler will be installed.
In linux it is: <tt>/usr/local/wince/cross-tools</tt>)
 
Make and make install. You may need to manually run ranlib on some generated libs
during making.
 
==== GCC ====
 
Checkout the [http://gcc.gnu.org/ GCC] source:
svn -q checkout -r {20050511} svn://gcc.gnu.org/svn/gcc/trunk gcc
(Note the date. It does not match the date in the VLC patches. Also, later revisions
contain severe bugs)
 
Now come the patches.
:* First apply the VLC [http://download.videolan.org/pub/testing/wince/patches/ GCC patch] (maybe a little fuzz here as well).
:* Then, patch <tt>gcc/stor-layout.c</tt> with the patch described [http://gcc.gnu.org/ml/gcc-patches/2006-10/msg01115.html here].
:* Finally, in <tt>gcc/config/arm/arm.h</tt>, stick the following define somewhere (before the architecture define is OK):
#define HANDLE_PRAGMA_PACK_PUSH_POP
In the root of the GCC source tree, make a directory called <tt>wince</tt>.
CD into it and create a file called <tt>build.sh</tt> with the following stuff (substitute PREFIX_TO_CROSS_COMPILER), and run it:<br>
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
|<tt>export PATH=PREFIX_TO_CROSS_COMPILER/bin:$PATH</tt><br>
<tt>../configure --with-gcc --with-gnu-ld --with-gnu-as --target=arm-wince-pe --prefix=PREFIX_TO_CROSS_COMPILER --disable-threads --disable-nls --enable-languages=c++ --disable-win32-registry --disable-interwork --disable-multilib</tt><br>
<tt>make install</tt>
|}
 
==== Finish up ====
 
We need to copy over some stuff from the full GCC tarball.
Get [http://download.videolan.org/pub/testing/wince/wince-arm-gcc4.0.0-cvs-linux-crosscompiler-20050517.tar.bz2 the binary tarball] and unpack it somewhere.
:* Copy recursively all of <tt>usr/local/wince/cross-tools/include/</tt> into your <tt>PREFIX_TO_CROSS_COMPILER/include</tt>.
:* Copy all of the libs in <tt>usr/local/wince/cross-tools/lib</tt> into your <tt>PREFIX_TO_CROSS_COMPILER/lib</tt> (except libiberty.a).
:* CD into your <tt>PREFIX_TO_CROSS_COMPILER/arm-wince-pe/lib</tt> and make the following two symbolic links:
ln -s ../../lib/corelibc.lib crt0.o
ln -s ../../lib/coredll.lib c.lib
Done :-)
 
(''Note:'' In linux, it is much easier to get the binary tarball, extract it into the root of the filesystem, and then build
the binutils and GCC replacing essentially the offending files (C++ compiler etc). This final step in this case is not be required)


=== ScummVM ===
=== ScummVM ===
''Assuming you have installed the toolchain in its default place''
Here is the procedure for building ScummVM:
 
This is the procedure for building ScummVM, provided the compiler is patched as described above:


* Build libraries from source
* Build libraries from source
You may skip this step if you downloaded the prebuilt library package.
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).
Download the original library source tarballs.
As an exception, get the Tremor snapshot from
Download the patches from [http://pocketinsanity.org/scummvm/libraries/ here] and patch the libraries.
[http://users.uoa.gr/~knakos/scummvm/libraries/tremor_2006_10_29.tar.bz2 here].
Please note that there is no patch available for zlib 1.2.5 as patching it is not needed any more (yay!).
Download the diffs from [http://users.uoa.gr/~knakos/scummvm/libraries/ here] and patch the libraries.
You need to ''configure'' and ''make'' each library,
You need to ''configure'' and ''make'' each library,
except the SDL library which sports a customly created (and lame :-) )
except for the SDL and Tremolo libraries which both sport a customly created (and lame :-) ) Makefile.
Makefile.
It should be sufficient to set the PATH to the following to make the toolchain usable:
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
|<tt>export PATH=/opt/mingw32ce/bin:$PATH</tt>
|}
Here are the typical parameters to the configure scripts:
Here are the typical parameters to the configure scripts:


:* FLAC:
* mad:
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
|<tt>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</tt>
|<tt>./configure --host=arm-mingw32ce --target=arm-mingw32ce</tt>
|}
|}


:*mad:
* libz:
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
|<tt>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</tt>
|<tt>CC=arm-mingw32ce-gcc AR=arm-mingw32ce-ar RANLIB=arm-mingw32ce-ranlib ./configure</tt>
|}
|}


:*mpeg2dec:
You just <tt>make</tt> each library after configuring.<br/>
The SDL and Tremolo libraries have no configuration script - you just <tt>make</tt>
 
* Place the library and include files in an appropriate place. In this example, we use /opt/mingw32ce/libraries
to keep them separate from the toolchain's libs and headers.
Here is an overview of the needed files, where to find them inside the specific library sourcetree, and where to put them:
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
|<tt>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</tt>
|<tt><pre>mad:
/path_to_patched_mad_sources/.libs/libmad.a -> /opt/mingw32ce/libraries/lib
/path_to_patched_mad_sources/mad.h -> /opt/mingw32ce/libraries/include
 
Tremolo:
/path_to_patched_tremolo_sources/libtremolo.a -> /opt/mingw32ce/libraries/lib
/path_to_patched_tremolo_sources/config_types.h -> /opt/mingw32ce/libraries/include/tremolo
/path_to_patched_tremolo_sources/ivorbiscodec.h -> /opt/mingw32ce/libraries/include/tremolo
/path_to_patched_tremolo_sources/ivorbisfile.h -> /opt/mingw32ce/libraries/include/tremolo
/path_to_patched_tremolo_sources/ogg.h -> /opt/mingw32ce/libraries/include/tremolo
/path_to_patched_tremolo_sources/os_types.h -> /opt/mingw32ce/libraries/include/tremolo
 
zlib:
/path_to_zlib_sources/libz.a -> /opt/mingw32ce/libraries/lib
/path_to_zlib_sources/z*.h -> /opt/mingw32ce/libraries/include
 
SDL:
/path_to_patched_sdl_sources/libSDL.a -> /opt/mingw32ce/libraries/lib
/path_to_patched_sdl_sources/include/* -> /opt/mingw32ce/libraries/include/SDL/*</pre></tt>
|}
|}


:*Tremor:
* Build
Please note that it may be needed to change the line "<tt>_host_alias=arm-wince-mingw32ce</tt>" to "<tt>_host_alias=arm-mingw32ce</tt>" in the ScummVM configure script if the compiler is not found.
For ScummVM we recommend a so called "out of source tree" build, so change to the ScummVM source directory and create a directory for that and run the configure script as following:
 
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
|<tt>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 ./autogen.sh --host=arm-wince-pe --target=arm-wince-pe</tt>
|<tt><pre>mkdir build-mingw32ce
cd build-mingw32ce
LDFLAGS="-L/opt/mingw32ce/libraries/lib" CXXFLAGS="-I/opt/mingw32ce/libraries/include -I/opt/mingw32ce/libraries/include/SDL" \
../configure --host=wince</pre></tt>
|}
|}


:*libz:
Of course you may use additional configuration switches like "<tt>--enable-release</tt>" or "<tt>--enable-engine(s)=xxx/--disable--engine(s)=yyy</tt>" as you like.
 
The libraries should now be automatically be detected by the configuration script, check the output for the following lines; if they're present everything should be ok:
 
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
|<tt>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</tt>
|<tt><pre>Checking for Tremor... yes
Checking for MAD... yes
Checking for zlib... yes
Backend... wince, savegame timestamp, HQ scalers</pre></tt>
|}
|}


You may also have to do some minor manual edits to the config.h files.
Finally do a <tt>make</tt> and after a while you should have a nice and shiny <tt>scummvm.exe</tt>.
(''libmad's one springs to mind, in which you have to undefine HAVE_STDINT_H'')
It's additionally recommended to do an "<tt>arm-mingw32ce-strip scummvm.exe</tt>" as the executable size is quite big (&gt; 85MB).


You just <tt>make</tt> each library after configuring.
Copy the resulting <tt>scummvm.exe</tt> along with the following files into a fresh folder on your device/emulator and give it a go:
The SDL library has no configuration script - you just <tt>make</tt>
{| style="padding: 1em; border: 1px dashed #2f6fab; color: black; background-color: #f9f9f9; line-height: 1.1em"
 
|<tt><pre>gui/themes/scummclassic.zip
* Place library files in appropriate places.
gui/themes/scummmodern.zip
Take a look at the Makefile to check out where the headers and libs are expected.
gui/themes/translations.dat
Currently they need to be under <tt>backends/platform/wince/libs/</tt> in directories
dists/pred.dic
<tt>include</tt> and <tt>lib</tt>.
dists/engine-data/drascula.dat
Also note that the Makefile expects the libraries to have somewhat more "funky" names than their default.
dists/engine-data/hugo.dat
This has been done for compatibility reasons with the evc built libs.
dists/engine-data/kyra.dat
Just rename the libraries according to the Makefile, or edit the Makefile to match the default naming.
dists/engine-data/lure.dat
 
dists/engine-data/queen.tbl
* Build
dists/engine-data/sky.cpt
cd into <tt>backends/platform/wince/</tt> and type <tt>make dist</tt>.
dists/engine-data/teenagent.dat
dists/engine-data/toon.dat</pre></tt>
|}

Latest revision as of 06:26, 27 July 2020

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 ScummVM for Windows CE 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 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 ScummVM for Windows CE.

Alright, ready? Let's go :-)

Get your gear together

Compilers

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 could use either evc3 or evc4 for those versions.
  • Version 0.9.x supported 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.
  • Version 1.0 and newer use the mingw32ce GCC cross compiler. This is only compiler being supported now. You may succeed in compiling with VS2005, but this is beyond the scope of these instructions.

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 change from our semi-custom VLC GCC port to cegcc was mandated because building dlls which are required by the plug-ins is broken in the former.

Finally we have switched to mingw32ce, which does not use the Unix compatibility layer which cegcc brings along as we don't need it.

Libraries

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

Tremolo is an ARM optimized version of the Tremor lib from [1]. For those that don't know, the Tremor lib is an integer-only library for doing Ogg Vorbis decompression.
MP3 sound files.
Handles all backend screen drawing.
Compressing/Decompressing files.

Arisme and Knakos have done an excellent job in porting all these libraries to Windows CE, along the process of porting ScummVM itself. Lately, this job is being done by CeRiAl.

Furthermore, the libraries need to be 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, Knakos' and CeRiAl's patches and are not incremental to them. A precompiled lib/header pack is available as well and you can find it right here.

Please note that some of those libraries have been officially ported to WinCE after the work done by Arisme/Knakos/CeRiAl 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 the mingw32ce GCC toolchain

First, you need to download and install the mingw32ce cross compiler. More specifically, you need the mingw32ce variety (without the posix layer emulation that is). You may optionally also download a working gdb debugger there for debugging the applications. Version 0.59.1 is the recommended version, your mileage may vary with other versions. It's also recommended, though not mandatory, to install the toolchain to /opt/mingw32ce (in the following example we use this directory).

ScummVM

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 tarballs. Download the patches from here and patch the libraries. Please note that there is no patch available for zlib 1.2.5 as patching it is not needed any more (yay!). You need to configure and make each library, except for the SDL and Tremolo libraries which both sport a customly created (and lame :-) ) Makefile. It should be sufficient to set the PATH to the following to make the toolchain usable:

export PATH=/opt/mingw32ce/bin:$PATH

Here are the typical parameters to the configure scripts:

  • mad:
./configure --host=arm-mingw32ce --target=arm-mingw32ce
  • libz:
CC=arm-mingw32ce-gcc AR=arm-mingw32ce-ar RANLIB=arm-mingw32ce-ranlib ./configure

You just make each library after configuring.
The SDL and Tremolo libraries have no configuration script - you just make

  • Place the library and include files in an appropriate place. In this example, we use /opt/mingw32ce/libraries

to keep them separate from the toolchain's libs and headers. Here is an overview of the needed files, where to find them inside the specific library sourcetree, and where to put them:

mad:
	/path_to_patched_mad_sources/.libs/libmad.a	-> /opt/mingw32ce/libraries/lib
	/path_to_patched_mad_sources/mad.h		-> /opt/mingw32ce/libraries/include

Tremolo:
	/path_to_patched_tremolo_sources/libtremolo.a	-> /opt/mingw32ce/libraries/lib
	/path_to_patched_tremolo_sources/config_types.h	-> /opt/mingw32ce/libraries/include/tremolo
	/path_to_patched_tremolo_sources/ivorbiscodec.h	-> /opt/mingw32ce/libraries/include/tremolo
	/path_to_patched_tremolo_sources/ivorbisfile.h	-> /opt/mingw32ce/libraries/include/tremolo
	/path_to_patched_tremolo_sources/ogg.h		-> /opt/mingw32ce/libraries/include/tremolo
	/path_to_patched_tremolo_sources/os_types.h	-> /opt/mingw32ce/libraries/include/tremolo

zlib:
	/path_to_zlib_sources/libz.a			-> /opt/mingw32ce/libraries/lib
	/path_to_zlib_sources/z*.h			-> /opt/mingw32ce/libraries/include

SDL:
	/path_to_patched_sdl_sources/libSDL.a		-> /opt/mingw32ce/libraries/lib
	/path_to_patched_sdl_sources/include/*		-> /opt/mingw32ce/libraries/include/SDL/*
  • Build

Please note that it may be needed to change the line "_host_alias=arm-wince-mingw32ce" to "_host_alias=arm-mingw32ce" in the ScummVM configure script if the compiler is not found. For ScummVM we recommend a so called "out of source tree" build, so change to the ScummVM source directory and create a directory for that and run the configure script as following:

mkdir build-mingw32ce
cd build-mingw32ce
LDFLAGS="-L/opt/mingw32ce/libraries/lib" CXXFLAGS="-I/opt/mingw32ce/libraries/include -I/opt/mingw32ce/libraries/include/SDL" \
../configure --host=wince

Of course you may use additional configuration switches like "--enable-release" or "--enable-engine(s)=xxx/--disable--engine(s)=yyy" as you like.

The libraries should now be automatically be detected by the configuration script, check the output for the following lines; if they're present everything should be ok:

Checking for Tremor... yes
Checking for MAD... yes
Checking for zlib... yes
Backend... wince, savegame timestamp, HQ scalers

Finally do a make and after a while you should have a nice and shiny scummvm.exe. It's additionally recommended to do an "arm-mingw32ce-strip scummvm.exe" as the executable size is quite big (> 85MB).

Copy the resulting scummvm.exe along with the following files into a fresh folder on your device/emulator and give it a go:

gui/themes/scummclassic.zip
gui/themes/scummmodern.zip
gui/themes/translations.dat
dists/pred.dic
dists/engine-data/drascula.dat
dists/engine-data/hugo.dat
dists/engine-data/kyra.dat
dists/engine-data/lure.dat
dists/engine-data/queen.tbl
dists/engine-data/sky.cpt
dists/engine-data/teenagent.dat
dists/engine-data/toon.dat