Difference between revisions of "Windows CE build instructions"

From Ultronomicon
Jump to navigation Jump to search
Line 1: Line 1:
== Set up environment variables ==
== Set up environment variables ==
  export CROSS_ROOT=/opt/cegcc
  export CROSS_ROOT=/opt/cegcc

Revision as of 04:35, 24 December 2007


Set up environment variables

export CROSS_ROOT=/opt/cegcc
export PRJ=$HOME/wince
export PATH=$CROSS_ROOT/bin:$PRJ/bin:/bin:/usr/bin

Create workspace directories

mkdir $PRJ
mkdir $PRJ/lib
mkdir $PRJ/pkg
mkdir $PRJ/bin

Install cegcc

  • Version 0.50 of cegcc was used. Several patches were submitted to cegcc team and the patches were committed to svn. If using version other than 0.50, ensure that the patches are there.
  • Download mandriva-cegcc-cegcc-0.50.tar.gz from http://cegcc.sourceforge.net/
  • Uncompress mandriva-cegcc-cegcc-0.50.tar.gz to /

Apply cegcc patches

  • Apply the followign to /opt/cegcc/arm-wince-cegcc/include/w32api/winuser.h:
Index: winuser.h
--- winuser.h   (revision 1066)
+++ winuser.h   (revision 1094)
@@ -1962,6 +1962,12 @@
 #define VK_OEM_2       0xBF
 #define VK_OEM_3       0xC0
+#define VK_APP1        0xC1
+#define VK_APP2        0xC2
+#define VK_APP3        0xC3
+#define VK_APP4        0xC4
+#define VK_APP5        0xC5
+#define VK_APP6        0xC6
 #define VK_OEM_4       0xDB
 #define VK_OEM_5       0xDC
 #define VK_OEM_6       0xDD
  • Apply the following to /opt/cegcc/arm-wince-cegcc/include/sys/dirent.h
Index: sys/dirent.h
--- sys/dirent.h        (revision 80)
+++ sys/dirent.h        (revision 1100)
@@ -36,6 +36,8 @@
 extern void rewinddir(DIR *dir);
 extern int  closedir(DIR *dir);

+extern int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
 #ifdef __cplusplus

Create cegcc symlinks

Create symbolic links to cegcc binaries. There are ways to avoid this step, and given more time it should be retired, but for now:

cd /opt/cegcc/bin
ls arm-wince-cegcc-* | while read line; do
    new_name=`echo $line | sed "s/arm-wince-cegcc-//g"`
    ln -s $line $new_name
    ln -s $line arm-wince-pe-$new_name

Build required libraries


cd $PRJ/pkg
wget http://www.libsdl.org/release/SDL-1.2.12.tar.gz
cd $PRJ
tar xvf pkg/SDL-1.2.12.tar.gz
  • Build SDL.dll using Visual Studio on win32 (having trouble cross-compiling in linux, hopefully will resolve shortly)...
  • Place SDL.dll that was built using Visual Studio to $PRJ/lib
  • Create $PRJ/bin/sdl-config:
if [ "$1" = "--version" ]; then
	echo "1.2.12"
elif [ "$1" = "--cflags" ]; then
	echo "-I${PRJ}/SDL-1.2.12/include"
elif [ "$1" = "--libs" ]; then
	echo "-L${PRJ}/lib -lSDL"
	exit 1
exit 0


cd $PRJ
svn co -r14321 http://svn.xiph.org/branches/lowmem-branch/Tremor
ln -s Tremor tremor
cd Tremor
./autogen.sh --host arm-wince-pe
./configure --host arm-wince-pe
gcc -shared *.o -o libvorbisidec.dll
cp libvorbisidec.dll $PRJ/lib


cd $PRJ/pkg
wget http://www.zlib.net/zlib-1.2.3.tar.gz
cd $PRJ
tar xvf zlib-1.2.3.tar.gz
cd $PRJ/zlib-1.2.3
export CC=arm-wince-cegcc-gcc
arm-wince-cegcc-gcc -shared adler32.o compress.o crc32.o deflate.o gzio.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o -o z.dll
cp z.dll $PRJ/lib
cd $PRJ/lib
ln -s z.dll zdll.dll


cd $PRJ/pkg
wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.24.tar.bz2
cd $PRJ
tar xvf libpng-1.2.24.tar.bz2
cd $PRJ/libpng-1.2.24
export CFLAGS=-I$PRJ/zlib-1.2.3
export LDFLAGS="-L$PRJ/lib"
arm-wince-cegcc-gcc -shared libpng12*.o -L$PRJ/lib -lz -o libpng.dll
cp libpng.dll $PRJ/pkg


cd $PRJ/pkg
wget http://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.6.tar.gz
cd $PRJ
tar xvf pkg/SDL_image-1.2.6.tar.gz
cd $PRJ/SDL_image-1.2.6
export CFLAGS="-I$PRJ/SDL-1.2.12/include -I$PRJ/libpng-1.2.24 -I$PRJ/zlib-1.2.3"
export LDFLAGS="-L$PRJ/lib -lpng"
./configure --enable-shared=yes --host arm-wince-pe arm-wince-pe
gcc -shared IMG*.o -L$PRJ/lib -lSDL -lpng -o SDL_image.dll
cp SDL_image.dll $PRJ/lib

Check out uqm sources

cd $PRJ
svn co -N https://sc2.svn.sourceforge.net/svnroot/sc2/trunk/sc2
cd sc2
svn up build doc src

Note: trunk is used in this example. Use whatever tag is appropriate.

Configure UQM

To configure UQM the following needs to be performed:

export CFLAGS="-I$PRJ/libvorbis-1.2.0/include -I$PRJ/libogg-1.1.3/include -I$PRJ/zlib-1.2.3 -I$PRJ/SDL-1.2.12/include -I$PRJ/zlib-1.2.3 -I$PRJ/SDL_image-1.2.6 -UUNICODE -I$PRJ -D_SYS_TYPES_FD_SET -DHAVE_STRING_H -D_WIN32_WCE"
export LDFLAGS="-L$PRJ/zlib-1.2.3 -L$PRJ/lib -L$PRJ/libogg-1.1.3/src/.libs -L$PRJ/libvorbis-1.2.0/lib/.libs -laygshell"
./build.sh uqm config

Run ./build.sh uqm config and set options to the following:

 1. Type of build                        Optimised release build
 2. OpenGL graphics support              Don't include OpenGL graphics support
 3. Sound backend                        Use MixSDL for sound (internal)
 4. Tracker music support                Included libmikmod
 5. Ogg Vorbis codec                     Tremor (avoids floating point math)
 6. Network Supermelee support           disabled
 7. Joystick support                     disabled
 8. Supported file i/o methods           Direct & .zip file i/o
 9. Graphics/Sound optimizations         Platform acceleration (asm, etc.)

Build UQM

Run ./build.sh uqm

Installing to WM device

For the purposes of this guide, $UQM_DIR denotes the directory where you want to install UQM (for example "/SD Card/uqm")

  1. Create the following directories:
    • $UQM_DIR/
    • $UQM_DIR/content/
    • $UQM_DIR/content/packages
  2. Place "uqm" executable into $UQM_DIR
  1. Place "version" file into $UQM_DIR/content
  2. Place main content file (for example uqm-0.6.0-content.uqm) into $UQM_DIR/content/packages
  3. Place any content patches / addon files into $UQM_DIR/content/packages
  4. Place wince addon file (for example uqm-0.6.0-~~wince_20071223.2200.zip) into $UQM_dir/content/packages

Adding UQM command-line arguments

  1. In WM5 file explorer, press on "uqm" and hold until pop-up menu appears.
  2. Select "Copy" menu item
  3. Press and hold in the file explorer window until pop-up menu appears.
  4. Select "Paste Shortcut" menu item
  5. Rename the newly created shortcut to "uqm_shortcut"
  6. Open "uqm_shortcut" in a text editor of choice and add command line arguments

Example shortcut file:

21#"\SD Card\uqm\uqm" -l uqm_log.txt



Always use same header files to build everything, doing otherwise brings chaos and is extremely difficult to debug

Missing DLLs

The following message usually means that your executable is unable to find a .dll:

The file 'uqm' cannot be opened. Either it is not sighed with a trusted certificate, or one of its components cannot be found. You might need to reinstall or restore this file.

To find out what dlls you are missing, run "arm-wince-gcc-objdump -p uqm" (or any of it's libraries)