This section describes several environment variables that affect how GCC operates. Some of them work by specifying directories or prefixes to use when searching for various kinds of files. Some are used to specify other aspects of the compilation environment.
Note that you can also specify places to search using options such as -B
, -I
and -L
(see Directory Options). These take precedence over places specified using environment variables, which in turn take precedence over those specified by the configuration of GCC. See Controlling the Compilation Driver gcc
.
LANG
LC_CTYPE
LC_MESSAGES
LC_ALL
LC_CTYPE
and LC_MESSAGES
if it has been configured to do so. These locale categories can be set to any value supported by your installation. A typical value is ‘en_GB.UTF-8
’ for English in the United Kingdom encoded in UTF-8. The LC_CTYPE
environment variable specifies character classification. GCC uses it to determine the character boundaries in a string; this is needed for some multibyte encodings that contain quote and escape characters that are otherwise interpreted as a string end or escape.
The LC_MESSAGES
environment variable specifies the language to use in diagnostic messages.
If the LC_ALL
environment variable is set, it overrides the value of LC_CTYPE
and LC_MESSAGES
; otherwise, LC_CTYPE
and LC_MESSAGES
default to the value of the LANG
environment variable. If none of these variables are set, GCC defaults to traditional C English behavior.
TMPDIR
TMPDIR
is set, it specifies the directory to use for temporary files. GCC uses temporary files to hold the output of one stage of compilation which is to be used as input to the next stage: for example, the output of the preprocessor, which is the input to the compiler proper. GCC_COMPARE_DEBUG
GCC_COMPARE_DEBUG
is nearly equivalent to passing -fcompare-debug
to the compiler driver. See the documentation of this option for more details. GCC_EXEC_PREFIX
GCC_EXEC_PREFIX
is set, it specifies a prefix to use in the names of the subprograms executed by the compiler. No slash is added when this prefix is combined with the name of a subprogram, but you can specify a prefix that ends with a slash if you wish. If GCC_EXEC_PREFIX
is not set, GCC attempts to figure out an appropriate prefix to use based on the pathname it is invoked with.
If GCC cannot find the subprogram using the specified prefix, it tries looking in the usual places for the subprogram.
The default value of GCC_EXEC_PREFIX
is prefix/lib/gcc/ where prefix is the prefix to the installed compiler. In many cases prefix is the value of prefix
when you ran the configure
script.
Other prefixes specified with -B
take precedence over this prefix.
This prefix is also used for finding files such as crt0.o
that are used for linking.
In addition, the prefix is used in an unusual way in finding the directories to search for header files. For each of the standard directories whose name normally begins with ‘/usr/local/lib/gcc
’ (more precisely, with the value of GCC_INCLUDE_DIR
), GCC tries replacing that beginning with the specified prefix to produce an alternate directory name. Thus, with -Bfoo/
, GCC searches foo/bar
just before it searches the standard directory /usr/local/lib/bar
. If a standard directory begins with the configured prefix then the value of prefix is replaced by GCC_EXEC_PREFIX
when looking for header files.
COMPILER_PATH
COMPILER_PATH
is a colon-separated list of directories, much like PATH
. GCC tries the directories thus specified when searching for subprograms, if it can't find the subprograms using GCC_EXEC_PREFIX
. LIBRARY_PATH
LIBRARY_PATH
is a colon-separated list of directories, much like PATH
. When configured as a native compiler, GCC tries the directories thus specified when searching for special linker files, if it can't find them using GCC_EXEC_PREFIX
. Linking using GCC also uses these directories when searching for ordinary libraries for the -l
option (but directories specified with -L
come first). LANG
LANG
are recognized: C-JIS
’C-SJIS
’C-EUCJP
’If LANG
is not defined, or if it has some other value, then the compiler uses mblen
and mbtowc
as defined by the default locale to recognize and translate multibyte characters.
Some additional environment variables affect the behavior of the preprocessor.
CPATH
C_INCLUDE_PATH
CPLUS_INCLUDE_PATH
OBJC_INCLUDE_PATH
PATH
, in which to look for header files. The special character, PATH_SEPARATOR
, is target-dependent and determined at GCC build time. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets it is a colon. CPATH
specifies a list of directories to be searched as if specified with -I
, but after any paths given with -I
options on the command line. This environment variable is used regardless of which language is being preprocessed.
The remaining environment variables apply only when preprocessing the particular language indicated. Each specifies a list of directories to be searched as if specified with -isystem
, but after any paths given with -isystem
options on the command line.
In all these variables, an empty element instructs the compiler to search its current working directory. Empty elements can appear at the beginning or end of a path. For instance, if the value of CPATH
is :/special/include
, that has the same effect as ‘-I. -I/special/include
’.
DEPENDENCIES_OUTPUT
The value of DEPENDENCIES_OUTPUT
can be just a file name, in which case the Make rules are written to that file, guessing the target name from the source file name. Or the value can have the form ‘file target’, in which case the rules are written to file file using target as the target name.
In other words, this environment variable is equivalent to combining the options -MM
and -MF
(see Preprocessor Options), with an optional -MT
switch too.
SUNPRO_DEPENDENCIES
DEPENDENCIES_OUTPUT
(see above), except that system header files are not ignored, so it implies -M
rather than -MM
. However, the dependence on the main input file is omitted. See Preprocessor Options.
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Environment-Variables.html