CeGCC cross compiler for PocketPC

Linker arguments to define

The linker allows for a number of parameters that influence the behaviour of Windows CE when the application runs. For example, the following record a field in the image header that tell the OS which version of CE the executable was targetted for:

The above reads as Windows CE 4.20.

CeGCC specifics

Predefined macros

By default, the arm-wince-cegcc-gcc C compiler is defining these macros :
__CEGCC__ Use this to identify our environment
__CEGCC32__ Identify our environment even more, we may have a 64-bit environment in the future.
unix This is a unix-like environment.
__unix__ This is a unix-like environment.
__unix This is a unix-like environment.
UNICODE Windows CE is a Unicode platform.
_UNICODE Windows CE is a Unicode platform.
ARM Identifies the processor in our target environment.
UNDER_CE
_M_ARM

Many of those are defined in src/gcc/gcc/config/arm/wince-pe.h . For the arm-wince-mingw32ce-gcc compiler, the source to watch is src/gcc/gcc/config/arm/mingw32.h . The list of predefined macros for that compiler is :
__MINGW32__ Use this to identify our environment.
__MINGW32CE__ Use this to identify our environment.
_WIN32 This is a Windows-32 environment.
WIN32 This is a Windows-32 environment.
WINNT
__COREDLL__ Used to signal we are linking against the coredll.dll runtime. Used mainly in the mingw sources and headers.

The unix macros defined by the compiler may appear strange. The arm-wince-cegcc-gcc compiler defines them to state that we're providing a unix-like layer on top of Windows, and that applications that run against a UNIX API might compile without change.

Compiler command line options

Option Macros defined Extra Libs/objects linked When to use
-mwin32 WIN32 Normal linking but macros indicate Windows environment, not Unix.
-mthreads crtmt.o instead of crtst.o multi-thread support, only needed for c++ apps using exceptions.

Macros that you may need to predefine

You may need to define these macros :
_WIN32_IE=0x0400 Required for CE version dependencies in the target include files. If you come to the conclusion you need this to expose some structure, define or function in the headers, and you are sure they are available in Windows CE, then the real fix is to fix the headers to not need the _WIN32_IE setting. Please report it to us.
_WIN32_WCE The _WIN32_WCE macro is used in several of the target include files to selectively enable some definitions based on the version of Windows CE that we're building for. For example, a device that runs a version of CE that identifies itself as 4.20.0, would match with a value of 0x0420 or lower.

A target include file is an include file, in our case borrowed from the MinGW project's w32api module, which our compiler uses to know things about the target environment.

Libraries

The CeGCC compilers automatically link in a library called libcegcc.a which has the dual job of being the import lib for cegcc.dll, and also works as a standard static lib that constains the startup code (WinMainCRTStartup, etc.)

The C compiler option -mwin32

In many cases, compiling sources requires some additional macros. We have chosen not to predefine these in the compiler, as they are target platform dependent. (Depends on the software version in your PDA or phone.) Here are some examples :

For the detail-hungry : what does it do and define

This output of a compiler run with the "-v" option shows exactly what it does, and which preprocessor symbols get defined. (Note: the below information is probably outdated, so be sure to run it yourself.)

dannypc: {73} arm-wince-cegcc-gcc -g -o fibo.exe fibo.c -v
Using built-in specs.
Target: arm-wince-cegcc
Configured with: /home/danny/src/cegcc/svn.sf.net/cegcc/trunk/cegcc/src/gcc/configure cegcc
Thread model: win32
gcc version 4.1.0
 /usr/ppc/libexec/gcc/arm-wince-cegcc/4.1.0/cc1 -quiet -v -D__CEGCC32__ -D__CEGCC__ -Dunix -D__unix__ -D__unix -idirafter /usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/lib/../include/w32api -idirafter ../../include/w32api fibo.c -quiet -dumpbase fibo.c -auxbase fibo -g -version -o /home/danny/tmp/ccbIfMcj.s
ignoring nonexistent directory "/usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/sys-include"
ignoring nonexistent directory "../../include/w32api"
#include "..." search starts here:
#include <...> search starts here:
 /usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/include
 /usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/include
 /usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/lib/../include/w32api
End of search list.
GNU C version 4.1.0 (arm-wince-cegcc)
        compiled by GNU C version 4.0.1 (4.0.1-5mdk for Mandriva Linux release 2006.0).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: cb5f549cfc80659543b9610e7bd1a54f
 /usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/bin/as -mfpu=vfp -o /home/danny/tmp/ccxaYCCS.o /home/danny/tmp/ccbIfMcj.s
 /usr/ppc/libexec/gcc/arm-wince-cegcc/4.1.0/collect2 -Bdynamic -o fibo.exe /usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/lib/crt0.o /usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/lib/crtst.o -L/usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0 -L/usr/ppc/lib/gcc/arm-wince-cegcc/4.1.0/../../../../arm-wince-cegcc/lib /home/danny/tmp/ccxaYCCS.o -lcegcc -lgcc -lcoredll -lcegcc -lgcc
Info: resolving _CRT_MT by linking to __imp__CRT_MT (auto-import)
dannypc: {74} 

Information

Support

Powered by Sourceforge.net