Chapter 24. Compiler and Linker Options
Table of Contents
eCos is built using the GNU C and C++ compilers. eCos relies on certain features of these tools such as constructor priority ordering and selective linking which are not part of other toolchains.
Some GCC options are required for eCos, and others can be useful. This chapter gives a brief description of the required options as well as some recommended eCos-specific options. All other GCC options (described in the GCC manuals) are available.
24.1. 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
|
$TARGET-
gcc -c -IECOS_INSTALL_DIR/include file.c $TARGET-
gcc -o program file.o -LECOS_INSTALL_DIR/lib -Ttarget.ld -nostdlib
Note | |
---|---|
Certain targets may require extra options, for example
the SPARClite architectures require the option
The following command lines use some other options which are recommended because they use the selective linking feature: |
$TARGET-
gcc -c -IECOS_INSTALL_DIR
/include -I. -ffunction-sections -fdata-sections -g \ -O2 file.c $TARGET-
gcc -o program file.o -ffunction-sections -fdata-sections -Wl,--gc-sections -g \ -O2 -LECOS_INSTALL_DIR
/lib -Ttarget.ld -nostdlib
24.2. 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
|
$TARGET-
g++ -c -IECOS_INSTALL_DIR
/include -fno-rtti -fno-exceptions file.cxx $TARGET-
g++ -o program file.o -LECOS_INSTALL_DIR
/lib -Ttarget.ld -nostdlib
Note | |
---|---|
Certain targets may require extra options,
for example the SPARClite architectures require the option
The following command lines use some other options which are recommended because they use the selective linking feature: |
$TARGET-
g++ -c -IECOS_INSTALL_DIR
/include -I. -ffunction-sections -fdata-sections -fno-rtti \ -fno-exceptions -finit-priority -g -O2 file.cxx $TARGET-
g++ -o program file.o -W1,--gc-sections -g -O2 -LECOS_INSTALL_DIR
/lib \ -Ttarget.ld -nostdlib
2024-12-10 | Open Publication License |