Difference between revisions of "Windows CE build instructions"

From Ultronomicon
Jump to navigation Jump to search
 
Line 2: Line 2:
 
  export CROSS_ROOT=/opt/cegcc
 
  export CROSS_ROOT=/opt/cegcc
 
  export PRJ=$HOME/wince
 
  export PRJ=$HOME/wince
  export PATH=.:$CROSS_ROOT/bin:$PRJ/bin:/bin:/usr/bin
+
  export PATH=$CROSS_ROOT/bin:$PRJ/bin:/bin:/usr/bin
  
 
== Create workspace directories ==
 
== Create workspace directories ==
Line 90: Line 90:
 
  ln -s Tremor tremor
 
  ln -s Tremor tremor
 
  cd Tremor
 
  cd Tremor
  autogen.sh --host arm-wince-pe
+
  ./autogen.sh --host arm-wince-pe
  configure --host arm-wince-pe
+
  ./configure --host arm-wince-pe
  make
+
  ./make
 
  gcc -shared *.o -o libvorbisidec.dll
 
  gcc -shared *.o -o libvorbisidec.dll
 
  cp libvorbisidec.dll $PRJ/lib
 
  cp libvorbisidec.dll $PRJ/lib
Line 105: Line 105:
 
  cd $PRJ/zlib-1.2.3
 
  cd $PRJ/zlib-1.2.3
 
  export CC=arm-wince-cegcc-gcc
 
  export CC=arm-wince-cegcc-gcc
  configure
+
  ./configure
  make
+
  ./make
 
  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
 
  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
 
  cp z.dll $PRJ/lib
Line 122: Line 122:
 
  export CFLAGS=-I$PRJ/zlib-1.2.3
 
  export CFLAGS=-I$PRJ/zlib-1.2.3
 
  export LDFLAGS="-L$PRJ/lib"
 
  export LDFLAGS="-L$PRJ/lib"
  configure
+
  ./configure
  make
+
  ./make
 
  arm-wince-cegcc-gcc -shared libpng12*.o -L$PRJ/lib -lz -o libpng.dll
 
  arm-wince-cegcc-gcc -shared libpng12*.o -L$PRJ/lib -lz -o libpng.dll
  
Line 136: Line 136:
 
  export CFLAGS="-I$PRJ/SDL-1.2.12/include -I$PRJ/libpng-1.2.24 -I$PRJ/zlib-1.2.3"
 
  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"
 
  export LDFLAGS="-L$PRJ/lib -lpng"
  configure --enable-shared=yes --host arm-wince-pe --target arm-wince-pe
+
  ./configure --enable-shared=yes --host arm-wince-pe arm-wince-pe
  make
+
  ./make
 
  gcc -shared IMG*.o -L$PRJ/lib -lSDL -lpng -o SDL_image.dll
 
  gcc -shared IMG*.o -L$PRJ/lib -lSDL -lpng -o SDL_image.dll
 
  cp SDL_image.dll $PRJ/lib
 
  cp SDL_image.dll $PRJ/lib
Line 155: Line 155:
 
  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"
 
  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"
 
  export MAKE_VERBOSE=1
 
  export MAKE_VERBOSE=1
  build.sh uqm config
+
  ./build.sh uqm config
  
Run build.sh uqm config and set options to the following:
+
Run ./build.sh uqm config and set options to the following:
 
   1. Type of build                        Optimised release build
 
   1. Type of build                        Optimised release build
 
   2. OpenGL graphics support              Don't include OpenGL graphics support
 
   2. OpenGL graphics support              Don't include OpenGL graphics support
Line 169: Line 169:
  
 
== Build UQM ==
 
== Build UQM ==
Run build.sh uqm
+
Run ./build.sh uqm
  
 
== Installing to WM device ==
 
== Installing to WM device ==
Line 178: Line 178:
 
#* $UQM_DIR/content/packages
 
#* $UQM_DIR/content/packages
 
# Place "uqm" executable into $UQM_DIR
 
# Place "uqm" executable into $UQM_DIR
 +
 
# Place "version" file into $UQM_DIR/content
 
# Place "version" file into $UQM_DIR/content
 
# Place main content file (for example uqm-0.6.0-content.uqm) into $UQM_DIR/content/packages
 
# Place main content file (for example uqm-0.6.0-content.uqm) into $UQM_DIR/content/packages
Line 192: Line 193:
 
Example shortcut file:
 
Example shortcut file:
 
  21#"\SD Card\uqm\uqm" -l uqm_log.txt
 
  21#"\SD Card\uqm\uqm" -l uqm_log.txt
 +
 +
== Gotchas ==
 +
=== Headers ===
 +
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)

Revision as of 03:48, 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 @@
 #endif
 #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
 };
 #endif

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
done

Build required libraries

SDL

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:
#!/bin/sh
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"
else
	exit 1
fi
exit 0

Tremor

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
./make
gcc -shared *.o -o libvorbisidec.dll
cp libvorbisidec.dll $PRJ/lib

zlib

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
./configure
./make
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

libpng

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"
./configure
./make
arm-wince-cegcc-gcc -shared libpng12*.o -L$PRJ/lib -lz -o libpng.dll

SDL_image

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
./make
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 BUILD_HOST=CEGCC
unset ENV BASH_ENV
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"
export MAKE_VERBOSE=1
./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

Gotchas

Headers

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)