CRT0 Libraries of STDLIB

This section explains the CRT0 libraries provided by STDLIB.

The following table lists the CRT0 libraries:

Simple Mode (thread local mode)


EABI Emulators Narrow char main (int argc, char *argv[], char *envp[])


EABI Emulators Wide char main (int argc, wchar_t *argv[], wchar_t *envp[])

Complex Mode (multi threaded mode / POSIX server mode)



EABI Emulators Narrow char main (int argc, char *argv[], char *envp[]


Emulators Narrow char main (int argc, char *argv[], char *envp[]) with stdxxx redirection to Win32 using RWin32Stream server


EABI Emulators Wide char wmain (int argc, wchar_t *argv[], wchar_t *envp[])


Emulator Wide char wmain (int argc, wchar_t *argv[], wchar_t *envp[]) with stdxxx redirection to Win32 using RWin32Stream server




Emulators: Provides the RWin32Stream server


EABI Emulators: Provides application specific redirection (for example, to Java RT or test applications).

These static libraries provide the compiler runtime glue code that runs from the Symbian E32Main() entry point for regular Symbian executables into the standard C main() entry point.

These executables are considered to be C programs hosted in a Symbian executable image. The glue code has a number of functions to perform, for example:

  • marshalling the process command arguments in the types used by main()

  • initialising the C Standard library context and mode of operation for example, calling SpawnPosixServerThread().

ECRT0.lib and the cleanup stack

A normal Symbian platform executable provides an E32Main() function which is called by the operating system to start the program. The file ecrt0.lib provides an E32Main() function for programs which use STDLIB. This function prepares the traditional argc and argv arguments, and passes them to main().

For a simple example demonstrating how to link to ecrt0.lib, see the description of the project specification for "Hello World" in Porting. The user of STDLIB need not use ecrt0.lib, and may provide their own E32Main(). In this case, a CTrapCleanup pointer should normally be provided. This pointer is required because although STDLIB does not call Symbian platform functions which can leave, it uses few functions which require a cleanup stack. Code in ecrt0.lib provides such a cleanup stack ("TheTrapCleanup "), but programs which do not link with ecrt0.lib must supply one directly.

For more details on the motivation behind Symbian's use of the cleanup stack, see Cleanup support.

NOTE: If the program is a UI application, that is, one that includes the following code in one of the source files:

GLDEF_C TInt E32Main()
    return EikStart::RunApplication(NewApplication);

then, the CTrapCleanup pointer is provided by the application framework.

Related concepts