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++.

Note: Remember that when this manual shows g++ you should type the full name of the cross compiler: mn10300-elf-g++, mips-tx39-elf-g++, powerpc-eabi-g++, sparclite-elf-g++, or arm-elf-g++. When compiling for the synthetic Linux target, use the native g++ which must have the features required by eCos.


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

Note: Certain targets may require extra options, for example the SPARClite architectures require the option -mcpu=sparclite. Examine the BASE_DIR/packages/targets file or BASE_DIR/examples/Makefile to see if any extra options are required, and if so, what they are.

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

$ g++ -c  -IINSTALL_DIR/include -I. -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority -g -O2 file.cxx
$ g++ -o program file.o -W1,--gc-sections -g -O2 -LINSTALL_DIR/lib -Ttarget.ld -nostdlib