Previous Page
Next Page

18.9. Option and Environment Variable Summary

This section summarizes frequently used GCC options for quick reference, and lists the environment variables used by GCC.

18.9.1. Command-Line Options


-c

Preprocess, compile, and assemble only (i.e., don't link).


-C

Leave comments in when preprocessing.


-D name[= definition]

Defines the symbol name.


-e name

Start program execution at name.


-E

Preprocess only; output to stdout, unless used with -o.


-ffast-math

Permit faster floating-point arithmetic methods at the cost of accuracy or precision.


-ffinite-math-only

Disregard infinities and NaN ("not a number") values.


-ffreestanding

Compile as a freestanding (not hosted) program.


-finline-functions, -fno-inline-functions

Enable/disable inline functions.


-fno-math-errno

Disable the errno variable for simple math functions.


-fno-trapping-math

Generate "nonstop" floating-point code.


-frounding-math

Don't disregard the rounding-mode features of the floating-point environment (experimental).


-fsignaling-nans

Allow all exceptions raised by signaling NaNs (experimental).


-fsyntax-only

Don't compile or link; just test input for syntax.


-funroll-loops, -fno-unroll-loops

Enable/disable loop optimization.


-funsafe-math-optimizations

Permit optimizations that don't conform to standards and/or don't verify values.


-fverbose-asm

Include C variable names as comments in assembly language.


-g[ format]

Compile for debugging.


-I directory[: directory[...]]

Search for "include" files in the specified path.


-I-

Distinguish between -Ipath for #include <file> and -Ipath for #include "file".


-l basename

Link with library libbasename.so or libbasename.a.


-L directory[: directory[...]]

Search for library files in the specified path.


-march= cpu

Intel x86: Generate model-specific code.


-mcpu= cpu

Sparc, ARM, and RS/6000-PowerPC: Generate model-specific code.

Intel x86: Optimize scheduling for the specified CPU model.


-mtune= cpu

Optimize scheduling for the specified CPU model.


-nostartfiles

Don't link startup code.


-nostdlib

Don't link with the standard library.


-o file

Direct output to the specified file.


-O0

Turn off all optimization options.


-O, -O1

Perform some optimization without taking much time.


-O2

Perform more optimization, including data flow analysis.


-O3

Perform still more optimization, including inline function compilation.


-Os

Optimize for size.


-p

Link in code to output profiling information.


-pedantic

Output warnings on nonstandard usage.


-pedantic-errors

Fail on nonstandard usage.


-pg

Link in code to output profiling information for gprof.


-s

Strip symbol tables from executable file.


-S

Preprocess and translate into assembly language only.


-save-temps

Save intermediate output files.


-shared

Create a shared object file for dynamic linking.


-static

Don't link to shared object files.


-std=iso9899:1990


-std=c89


-ansi

Support ISO/IEC 9899:1990.


-std=iso9899:199409

Support ISO/IEC 9899:1989 and AMD1.


-std=c99

Support ISO/IEC 9899:1999.


-std=gnu89

Like -ansi, plus GNU extensions (default).


-std=gnu99

Like -std=c99, plus GNU extensions.


-traditional

Support old-style C. Deprecated; supported only with -E.


-trigraphs

Support ISO C trigraphs.


-U name

"Undefine" the symbol name.


-v

Be verbose: print the options applied at each step of compiling.


--version

Output GCC version and license information.


-w

Disable all warnings.


-Wa, option[, option[...]]

Pass options to assembler command line.


-Wall

Output warnings about a broad range of problems in source code.


-Wl, option[, option[...]]

Pass options to linker command line.


-Werror

Fail on all warnings.


-Wextra

Output warnings about legal but questionable usage.


-Wtraditional

Warn about differences to old-style C.


-fmerge-constants

Put identical constants in a single location.


-x filetype

Treat subsequent files as being of the specified type.

18.9.2. Environment Variables


CPATH, C_INCLUDE_PATH

Colon-separated list of directories to search for header files, after those indicated by -Idirectory on the command line.


COMPILER_PATH

Colon-separated list of directories to search for GCC's own subprogram files.


GCC_EXEC_PREFIX

A prefix for GCC to add to the names of its subprograms when invoking them. May end with a slash.


LIBRARY_PATH

Colon-separated list of directories to search for linker and library files, after directories specified by -Ldirectory on the command line.


LD_LIBRARY_PATH

Colon-separated list of directories to search for shared library files. Read not by GCC, but by executables dynamically linked against shared libraries.


TMPDIR

Directory to use for temporary files.


Previous Page
Next Page