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.
option tells the GCC to compile the file specified after the option. By default an object file with the same name but the
extensions will be generated.
options will start compilation but stop at specific processing steps and generate an output file of the appropriate type.
option specifies the output file name and overrides the default (<source-name>.o
when compiling, a.out
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