Chapter 6. Compiler and linker options

Table of Contents
Compiling a C application
Compiling a C++ application

eCos is built using the GNU C and C++ compilers. The versions of the tools Cygnus has prepared for this release have some enhancements, such as constructor priority ordering and selective linking, which will eventually become part of the standard distribution.

Some GCC options are required for eCos, and others can be useful. This guide gives a brief description of the required options as well as some recommended eCos-specific options. All other GCC options described in the GNUPro manuals are still available.

Compiling a C application

The following command lines demonstrate the minimum set of options required to compile and link an eCos program written in C. Remember that when this manual shows gcc you should type the full name of the cross compiler: mn10300-elf-gcc, mips-tx39-elf-gcc, or powerpc-eabi-gcc.

$ gcc -c  -IINSTALL_DIR/include -fno-rtti -fno-exceptions file.cxx
$ gcc -o program file.o -LINSTALL_DIR/lib -Ttarget.ld -nostdlib

The following command lines use some other options which are recommended because they use the selective linking feature:

$ gcc -c  -IINSTALL_DIR/include -I. -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -g -O2 file.cxx
$ gcc -o program file.o -ffunction-sections -fdata-sections -Wl,--gc-sections -g -O2 -LINSTALL_DIR/lib -Ttarget.ld -nostdlib