When you invoke GCC, it normally does preprocessing, compilation,
assembly and linking. The “overall options” allow you to stop this
process at an intermediate stage. For example, the
says not to run the linker. Then the output consists of object files
output by the assembler.
See Options Controlling the Kind of Output.
Other options are passed on to one or more stages of processing. Some options control the preprocessor and others the compiler itself. Yet other options control the assembler and linker; most of these are not documented here, since you rarely need to use any of them.
Most of the command-line options that you can use with GCC are useful for C programs; when an option is only useful with another language (usually C++), the explanation says so explicitly. If the description for a particular option does not mention a source language, you can use that option with all supported languages.
The usual way to run GCC is to run the executable called
machine-gcc when cross-compiling, or
machine-gcc-version to run a specific version of GCC.
When you compile C++ programs, you should invoke GCC as
instead. See Compiling C++ Programs,
for information about the differences in behavior between
g++ when compiling C++ programs.
gcc program accepts options and file names as operands. Many
options have multi-letter names; therefore multiple single-letter options
may not be grouped:
-dv is very different from ‘
You can mix options and other arguments. For the most part, the order
you use doesn’t matter. Order does matter when you use several
options of the same kind; for example, if you specify
than once, the directories are searched in the order specified. Also,
the placement of the
-l option is significant.
Many options have long names starting with ‘
-f’ or with
-Wformat and so on. Most of
these have both positive and negative forms; the negative form of
-fno-foo. This manual documents
only one of these two forms, whichever one is not the default.
Some options take one or more arguments typically separated either
by a space or by the equals sign (‘
=’) from the option name.
Unless documented otherwise, an argument can be either numeric or
a string. Numeric arguments must typically be small unsigned decimal
or hexadecimal integers. Hexadecimal arguments must begin with
0x’ prefix. Arguments to options that specify a size
threshold of some sort may be arbitrarily large decimal or hexadecimal
integers followed by a byte size suffix designating a multiple of bytes
KiB for kilobyte and kibibyte, respectively,
MiB for megabyte and mebibyte,
GiB for gigabyte and gigibyte, and so on. Such arguments are
byte-size in the following text. Refer to the NIST,
IEC, and other relevant national and international standards for the full
listing and explanation of the binary and decimal byte size prefixes.
See Option Index, for an index to GCC’s options.
|• Option Summary:||Brief list of all options, without explanations.|
|• Overall Options:||Controlling the kind of output:
an executable, object files, assembler files, or preprocessed source.
|• Invoking G++:||Compiling C++ programs.|
|• C Dialect Options:||Controlling the variant of C language compiled.|
|• C++ Dialect Options:||Variations on C++.|
|• Objective-C and Objective-C++ Dialect Options:||Variations on Objective-C
|• Diagnostic Message Formatting Options:||Controlling how diagnostics should
|• Warning Options:||How picky should the compiler be?|
|• Static Analyzer Options:||More expensive warnings.|
|• Debugging Options:||Producing debuggable code.|
|• Optimize Options:||How much optimization?|
|• Instrumentation Options:||Enabling profiling and extra run-time error checking.|
|• Preprocessor Options:||Controlling header files and macro definitions.
Also, getting dependency information for Make.
|• Assembler Options:||Passing options to the assembler.|
|• Link Options:||Specifying libraries and so on.|
|• Directory Options:||Where to find header files and libraries.
Where to find the compiler executable files.
|• Code Gen Options:||Specifying conventions for function calls, data layout
and register usage.
|• Developer Options:||Printing GCC configuration info, statistics, and
|• Submodel Options:||Target-specific options, such as compiling for a
specific processor variant.
|• Spec Files:||How to pass switches to sub-processes.|
|• Environment Variables:||Env vars that affect GCC.|
|• Precompiled Headers:||Compiling a header once, and using it many times.|