Difference between revisions of "Windows CE build instructions"

From Ultronomicon
Jump to navigation Jump to search
 
(17 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
[[Image:uqm_ce.jpg|thumb|320px|The Ur-Quan Masters running on Dell Axim x51v]]
 
[[Image:uqm_ce.jpg|thumb|320px|The Ur-Quan Masters running on Dell Axim x51v]]
 +
 +
== VMWare image ==
 +
Ready-to-compile VMWare image of Ubuntu 7.10 server is [http://uqm.stack.nl/files/other/ptx/wince/ubuntu_uqm_wince_20080405.zip available here].
 +
User name: uqm
 +
Password: uqm
 +
 +
The '''uqm''' user has sudo privileges. You should probably change the password.
 +
 +
See ~/readme.txt for additional details.
 +
 
== Set up environment variables ==
 
== Set up environment variables ==
 
  export CROSS_ROOT=/opt/cegcc
 
  export CROSS_ROOT=/opt/cegcc
Line 85: Line 95:
  
 
==== Patch headers ====
 
==== Patch headers ====
 +
SDL-1.2.12 headers need to be patched for successful compilation of SDL_image and The Ur-Quan Masters. Note that when building SDL using win32 Visual Studio, the headers must also be patched there (for the APP1-6 keys to be available).
 +
 
  --- orig/SDL-1.2.12/include/SDL_config_minimal.h        2007-07-20 01:52:44.000000000 -0400
 
  --- orig/SDL-1.2.12/include/SDL_config_minimal.h        2007-07-20 01:52:44.000000000 -0400
 
  +++ wince/SDL-1.2.12/include/SDL_config_minimal.h      2007-12-24 11:50:58.000000000 -0500
 
  +++ wince/SDL-1.2.12/include/SDL_config_minimal.h      2007-12-24 11:50:58.000000000 -0500
Line 164: Line 176:
 
  ./autogen.sh --host arm-wince-pe
 
  ./autogen.sh --host arm-wince-pe
 
  ./configure --host arm-wince-pe
 
  ./configure --host arm-wince-pe
  ./make
+
  make
 
  arm-wince-cegcc-gcc -shared *.o -o libvorbisidec.dll
 
  arm-wince-cegcc-gcc -shared *.o -o libvorbisidec.dll
 
  cp libvorbisidec.dll $PRJ/lib
 
  cp libvorbisidec.dll $PRJ/lib
Line 178: Line 190:
 
  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 194: Line 206:
 
  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 --host arm-wince-pe
  ./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
  cp libpng.dll $PRJ/pkg
+
  cp libpng.dll $PRJ/lib
  
 
=== SDL_image ===
 
=== SDL_image ===
Line 209: Line 221:
 
  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 arm-wince-pe
+
  ./configure --enable-shared=yes --host 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 242: Line 254:
  
 
== Build The Ur-Quan Masters ==
 
== Build The Ur-Quan Masters ==
Run ./build.sh uqm
+
<code>
 +
./build.sh uqm
 +
</code>
 +
 
 +
== Compress binaries ==
 +
Use [http://upx.sourceforge.net UPX] to make the binaries WM6.1-compatible.
 +
 
 +
upx *.exe *.dll
  
 
== Installing to WM device ==
 
== 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")
+
For the purposes of this guide, $UQM_DIR denotes the directory where you want to install The Ur-Quan Masters (for example "/SD Card/uqm")
 
# Create the following directories:
 
# Create the following directories:
 
#* $UQM_DIR/
 
#* $UQM_DIR/
Line 252: Line 271:
 
# Place "uqm" executable into $UQM_DIR
 
# Place "uqm" executable into $UQM_DIR
 
# Place shared libraries into $UQM_DIR:
 
# Place shared libraries into $UQM_DIR:
#* $PRJ/libpng.dll
+
#* $PRJ/lib/libpng.dll
#* $PRJ/libvorbisidec.dll
+
#* $PRJ/lib/libvorbisidec.dll
#* $PRJ/SDL.dll
+
#* $PRJ/lib/SDL.dll
#* $PRJ/SDL_image.dll
+
#* $PRJ/lib/SDL_image.dll
#* $PRJ/z.dll
+
#* $PRJ/lib/z.dll
 
#* /opt/cegcc/arm-wince-cegcc/lib/device/cegcc.dll
 
#* /opt/cegcc/arm-wince-cegcc/lib/device/cegcc.dll
 
# 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
 
# Place any content patches / addon files into $UQM_DIR/content/packages
 
# Place any content patches / addon files into $UQM_DIR/content/packages
# Place wince addon file (for example uqm-0.6.0-~~wince_20071223.2200.zip) into $UQM_dir/content/packages
+
# Place wince addon file (for example uqm-0.6.0-~~wince_20071223.2200.zip) into $UQM_dir/content/packages. Note that this "addon" file should contain any custom Wince settings, like key mappings.
  
 
== Adding The Ur-Quan Masters command-line arguments ==
 
== Adding The Ur-Quan Masters command-line arguments ==
 
# In WM5 file explorer, press on "uqm" and hold until pop-up menu appears.
 
# In WM5 file explorer, press on "uqm" and hold until pop-up menu appears.
 
# Select "Copy" menu item
 
# Select "Copy" menu item
# Press and hold in the file explorer window until pop-up menu appears.
+
# Press and hold somewhere (not on a file name) in the file explorer window until pop-up menu appears.
 
# Select "Paste Shortcut" menu item
 
# Select "Paste Shortcut" menu item
 
# Rename the newly created shortcut to "uqm_shortcut"
 
# Rename the newly created shortcut to "uqm_shortcut"
Line 272: Line 291:
 
Example shortcut file:
 
Example shortcut file:
 
  21#"\SD Card\uqm\uqm" -l uqm_log.txt
 
  21#"\SD Card\uqm\uqm" -l uqm_log.txt
 +
 +
== Notes ==
 +
* Netplay is not yet supported
 +
* OpenGL is not yet supported
  
 
== Gotchas ==
 
== Gotchas ==
Line 278: Line 301:
 
=== Missing DLLs ===
 
=== Missing DLLs ===
 
The following message usually means that your executable is unable to find a .dll:
 
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.
+
  The file 'uqm' cannot be opened. Either it is not signed 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)
 
To find out what dlls you are missing, run "arm-wince-gcc-objdump -p uqm" (or any of it's libraries)
  
 
[[Category:About the Star Control series]]
 
[[Category:About the Star Control series]]

Latest revision as of 00:40, 27 February 2009

The Ur-Quan Masters running on Dell Axim x51v

VMWare image[edit]

Ready-to-compile VMWare image of Ubuntu 7.10 server is available here.

User name: uqm
Password: uqm

The uqm user has sudo privileges. You should probably change the password.

See ~/readme.txt for additional details.

Set up environment variables[edit]

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

Create workspace directories[edit]

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

Install cegcc[edit]

  • 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[edit]

  • 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[edit]

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[edit]

SDL[edit]

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

Patch headers[edit]

SDL-1.2.12 headers need to be patched for successful compilation of SDL_image and The Ur-Quan Masters. Note that when building SDL using win32 Visual Studio, the headers must also be patched there (for the APP1-6 keys to be available).

--- orig/SDL-1.2.12/include/SDL_config_minimal.h        2007-07-20 01:52:44.000000000 -0400
+++ wince/SDL-1.2.12/include/SDL_config_minimal.h       2007-12-24 11:50:58.000000000 -0500
@@ -36,7 +36,9 @@
 typedef signed int int32_t;
 typedef unsigned int uint32_t;
 typedef unsigned int size_t;
+#ifndef __CEGCC__
 typedef unsigned long uintptr_t;
+#endif
 
 /* Enable the dummy audio driver (src/audio/dummy/\*.c) */
 #define SDL_AUDIO_DRIVER_DUMMY 1
--- orig/SDL-1.2.12/./include/SDL_keysym.h      2007-07-20 01:52:44.000000000 -0400
+++ wince/SDL-1.2.12/./include/SDL_keysym.h     2007-12-23 20:16:11.000000000 -0500
@@ -282,6 +282,12 @@
        SDLK_UNDO               = 322,          /* Atari keyboard has Undo */
 
        /* Add any other keys here */
+       SDLK_APP1               = 323,
+       SDLK_APP2               = 324,
+       SDLK_APP3               = 325,
+       SDLK_APP4               = 326,
+       SDLK_APP5               = 327,
+       SDLK_APP6               = 328,
 
        SDLK_LAST
 } SDLKey;
--- orig/SDL-1.2.12/include/SDL_stdinc.h        2007-07-20 01:52:44.000000000 -0400
+++ wince/SDL-1.2.12/include/SDL_stdinc.h       2007-12-24 11:53:11.000000000 -0500
@@ -57,13 +57,15 @@
 # endif
 # include <string.h>
 #endif
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-#if defined(HAVE_INTTYPES_H)
-# include <inttypes.h>
-#elif defined(HAVE_STDINT_H)
-# include <stdint.h>
+#ifndef __CEGCC__
+# ifdef HAVE_STRINGS_H
+#  include <strings.h>
+# endif
+# if defined(HAVE_INTTYPES_H)
+#  include <inttypes.h>
+# elif defined(HAVE_STDINT_H)
+#  include <stdint.h>
+# endif
 #endif
 #ifdef HAVE_CTYPE_H
 # include <ctype.h>
--- sdlorig/SDL-1.2.12/./src/video/windib/SDL_dibevents.c       2007-07-20 01:52:19.000000000 -0400
+++ wince/SDL-1.2.12/./src/video/windib/SDL_dibevents.c 2007-12-23 20:14:55.000000000 -0500
@@ -430,6 +430,13 @@
        VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
        VK_keymap[VK_CANCEL] = SDLK_BREAK;
        VK_keymap[VK_APPS] = SDLK_MENU;
+
+       VK_keymap[VK_APP1] = SDLK_APP1;
+       VK_keymap[VK_APP2] = SDLK_APP2;
+       VK_keymap[VK_APP3] = SDLK_APP3;
+       VK_keymap[VK_APP4] = SDLK_APP4;
+       VK_keymap[VK_APP5] = SDLK_APP5;
+       VK_keymap[VK_APP6] = SDLK_APP6;
 }

Tremor[edit]

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

zlib[edit]

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[edit]

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

SDL_image[edit]

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
make
gcc -shared IMG*.o -L$PRJ/lib -lSDL -lpng -o SDL_image.dll
cp SDL_image.dll $PRJ/lib

Check out The Ur-Quan Masters sources[edit]

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 The Ur-Quan Masters build scripts[edit]

To configure The Ur-Quan Masters 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 The Ur-Quan Masters[edit]

./build.sh uqm

Compress binaries[edit]

Use UPX to make the binaries WM6.1-compatible.

upx *.exe *.dll

Installing to WM device[edit]

For the purposes of this guide, $UQM_DIR denotes the directory where you want to install The Ur-Quan Masters (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
  3. Place shared libraries into $UQM_DIR:
    • $PRJ/lib/libpng.dll
    • $PRJ/lib/libvorbisidec.dll
    • $PRJ/lib/SDL.dll
    • $PRJ/lib/SDL_image.dll
    • $PRJ/lib/z.dll
    • /opt/cegcc/arm-wince-cegcc/lib/device/cegcc.dll
  4. Place "version" file into $UQM_DIR/content
  5. Place main content file (for example uqm-0.6.0-content.uqm) into $UQM_DIR/content/packages
  6. Place any content patches / addon files into $UQM_DIR/content/packages
  7. Place wince addon file (for example uqm-0.6.0-~~wince_20071223.2200.zip) into $UQM_dir/content/packages. Note that this "addon" file should contain any custom Wince settings, like key mappings.

Adding The Ur-Quan Masters command-line arguments[edit]

  1. In WM5 file explorer, press on "uqm" and hold until pop-up menu appears.
  2. Select "Copy" menu item
  3. Press and hold somewhere (not on a file name) 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.lnk" in a text editor of choice and add command line arguments

Example shortcut file:

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

Notes[edit]

  • Netplay is not yet supported
  • OpenGL is not yet supported

Gotchas[edit]

Headers[edit]

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

Missing DLLs[edit]

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

The file 'uqm' cannot be opened. Either it is not signed 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)