Creating an application
ARM DUI 0529C Copyright © 2010-2011 ARM. All rights reserved. 3-3
ID080411 Non-Confidential
3.2 Using the compiler
The compiler,
armcc
, can compile C and C++ source code into ARM and Thumb code.
Typically, you invoke the compiler as follows:
armcc [options] ifile_1 ... ifile_n
You can specify one or more input files.
3.2.1 Compiling example
To compile the C++ example source file
shapes.cpp
:
1. Compile the C++ file
shapes.cpp
with the following command:
armcc --cpp --debug -c -O1 shapes.cpp -o shapes.o
The following options are commonly used:
-c
Tells the compiler to compile only, and not link.
-cpp
Tells the compiler that the source is C++.
--debug
Tells the compiler to add debug tables for source-level debugging.
-O1
Tells the compiler to generate code with restricted optimizations
applied to give a satisfactory debug view with good code density and
performance.
-o filename
Tells the compiler to create an object file with the specified
filename
.
Be aware that
--arm
is the default compiler option.
2. Link the file:
armlink shapes.o --info totals -o shapes.axf
3. Use an ELF, DWARF 2, and DWARF 3 compatible debugger to load and run the image.
See the
readme.txt
file that accompanies the example for more information.
3.2.2 Compiling for ARM code
The following compiler options generate ARM code:
--arm
Tells the compiler to generate ARM code in preference to Thumb code. However,
#pragma thumb
overrides this option.
This is the default compiler option.
--arm_only
Forces the compiler to generate only ARM code. The compiler behaves as if
Thumb is absent from the target architecture. Any
#pragma thumb
declarations are
ignored.
3.2.3 Compiling for Thumb code
To build a Thumb version use:
armcc --thumb ...