The process of creating an executable program consists of two steps:
- Compiling the source files which creates object files
- Linking the object files and optional libraries which creates an executable file
This requires two tools: A compiler and a linker.
The GCC is both and the passed command line options specify what should be done.
The
-c
option tells the GCC to compile the file specified after the option. By default an object file with the same name but the
.o
extensions will be generated.
The
-E
and
-S
options will start compilation but stop at specific processing steps and generate an output file of the appropriate type.
The
-o
option specifies the output file name and overrides the default (
<source-name>.o when compiling,
a.out when linking).
Invoking GCC with source file names only is a special case:
It will compile the source files (generate object files), link the object files to create an executable file (
a.out), and deletes the object files.
For an overview of all options see
Using the GNU Compiler Collection (GCC): Option Summary[
^].