<html lang="en"> <head> <title>Environment Variables - Using the GNU Compiler Collection (GCC)</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Using the GNU Compiler Collection (GCC)"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC"> <link rel="prev" href="Code-Gen-Options.html#Code-Gen-Options" title="Code Gen Options"> <link rel="next" href="Precompiled-Headers.html#Precompiled-Headers" title="Precompiled Headers"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1988-2015 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being ``Funding Free Software'', the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled ``GNU Free Documentation License''. (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development.--> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Environment-Variables"></a> <p> Next: <a rel="next" accesskey="n" href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>, Previous: <a rel="previous" accesskey="p" href="Code-Gen-Options.html#Code-Gen-Options">Code Gen Options</a>, Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a> <hr> </div> <h3 class="section">3.19 Environment Variables Affecting GCC</h3> <p><a name="index-environment-variables-2836"></a> <!-- man begin ENVIRONMENT --> 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. <p>Note that you can also specify places to search using options such as <samp><span class="option">-B</span></samp>, <samp><span class="option">-I</span></samp> and <samp><span class="option">-L</span></samp> (see <a href="Directory-Options.html#Directory-Options">Directory Options</a>). These take precedence over places specified using environment variables, which in turn take precedence over those specified by the configuration of GCC. See <a href="../gccint/Driver.html#Driver">Controlling the Compilation Driver <samp><span class="file">gcc</span></samp></a>. <dl> <dt><samp><span class="env">LANG</span></samp><dt><samp><span class="env">LC_CTYPE</span></samp><dd><!-- @itemx LC_COLLATE --> <dt><samp><span class="env">LC_MESSAGES</span></samp><dd><!-- @itemx LC_MONETARY --> <!-- @itemx LC_NUMERIC --> <!-- @itemx LC_TIME --> <dt><samp><span class="env">LC_ALL</span></samp><dd><a name="index-LANG-2837"></a><a name="index-LC_005fCTYPE-2838"></a><!-- @findex LC_COLLATE --> <a name="index-LC_005fMESSAGES-2839"></a><!-- @findex LC_MONETARY --> <!-- @findex LC_NUMERIC --> <!-- @findex LC_TIME --> <a name="index-LC_005fALL-2840"></a><a name="index-locale-2841"></a>These environment variables control the way that GCC uses localization information which allows GCC to work with different national conventions. GCC inspects the locale categories <samp><span class="env">LC_CTYPE</span></samp> and <samp><span class="env">LC_MESSAGES</span></samp> 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 ‘<samp><span class="samp">en_GB.UTF-8</span></samp>’ for English in the United Kingdom encoded in UTF-8. <p>The <samp><span class="env">LC_CTYPE</span></samp> 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. <p>The <samp><span class="env">LC_MESSAGES</span></samp> environment variable specifies the language to use in diagnostic messages. <p>If the <samp><span class="env">LC_ALL</span></samp> environment variable is set, it overrides the value of <samp><span class="env">LC_CTYPE</span></samp> and <samp><span class="env">LC_MESSAGES</span></samp>; otherwise, <samp><span class="env">LC_CTYPE</span></samp> and <samp><span class="env">LC_MESSAGES</span></samp> default to the value of the <samp><span class="env">LANG</span></samp> environment variable. If none of these variables are set, GCC defaults to traditional C English behavior. <br><dt><samp><span class="env">TMPDIR</span></samp><dd><a name="index-TMPDIR-2842"></a>If <samp><span class="env">TMPDIR</span></samp> 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. <br><dt><samp><span class="env">GCC_COMPARE_DEBUG</span></samp><dd><a name="index-GCC_005fCOMPARE_005fDEBUG-2843"></a>Setting <samp><span class="env">GCC_COMPARE_DEBUG</span></samp> is nearly equivalent to passing <samp><span class="option">-fcompare-debug</span></samp> to the compiler driver. See the documentation of this option for more details. <br><dt><samp><span class="env">GCC_EXEC_PREFIX</span></samp><dd><a name="index-GCC_005fEXEC_005fPREFIX-2844"></a>If <samp><span class="env">GCC_EXEC_PREFIX</span></samp> 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. <p>If <samp><span class="env">GCC_EXEC_PREFIX</span></samp> is not set, GCC attempts to figure out an appropriate prefix to use based on the pathname it is invoked with. <p>If GCC cannot find the subprogram using the specified prefix, it tries looking in the usual places for the subprogram. <p>The default value of <samp><span class="env">GCC_EXEC_PREFIX</span></samp> is <samp><var>prefix</var><span class="file">/lib/gcc/</span></samp> where <var>prefix</var> is the prefix to the installed compiler. In many cases <var>prefix</var> is the value of <code>prefix</code> when you ran the <samp><span class="file">configure</span></samp> script. <p>Other prefixes specified with <samp><span class="option">-B</span></samp> take precedence over this prefix. <p>This prefix is also used for finding files such as <samp><span class="file">crt0.o</span></samp> that are used for linking. <p>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 ‘<samp><span class="samp">/usr/local/lib/gcc</span></samp>’ (more precisely, with the value of <samp><span class="env">GCC_INCLUDE_DIR</span></samp>), GCC tries replacing that beginning with the specified prefix to produce an alternate directory name. Thus, with <samp><span class="option">-Bfoo/</span></samp>, GCC searches <samp><span class="file">foo/bar</span></samp> just before it searches the standard directory <samp><span class="file">/usr/local/lib/bar</span></samp>. If a standard directory begins with the configured <var>prefix</var> then the value of <var>prefix</var> is replaced by <samp><span class="env">GCC_EXEC_PREFIX</span></samp> when looking for header files. <br><dt><samp><span class="env">COMPILER_PATH</span></samp><dd><a name="index-COMPILER_005fPATH-2845"></a>The value of <samp><span class="env">COMPILER_PATH</span></samp> is a colon-separated list of directories, much like <samp><span class="env">PATH</span></samp>. GCC tries the directories thus specified when searching for subprograms, if it can't find the subprograms using <samp><span class="env">GCC_EXEC_PREFIX</span></samp>. <br><dt><samp><span class="env">LIBRARY_PATH</span></samp><dd><a name="index-LIBRARY_005fPATH-2846"></a>The value of <samp><span class="env">LIBRARY_PATH</span></samp> is a colon-separated list of directories, much like <samp><span class="env">PATH</span></samp>. 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 <samp><span class="env">GCC_EXEC_PREFIX</span></samp>. Linking using GCC also uses these directories when searching for ordinary libraries for the <samp><span class="option">-l</span></samp> option (but directories specified with <samp><span class="option">-L</span></samp> come first). <br><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LANG-2847"></a><a name="index-locale-definition-2848"></a>This variable is used to pass locale information to the compiler. One way in which this information is used is to determine the character set to be used when character literals, string literals and comments are parsed in C and C++. When the compiler is configured to allow multibyte characters, the following values for <samp><span class="env">LANG</span></samp> are recognized: <dl> <dt>‘<samp><span class="samp">C-JIS</span></samp>’<dd>Recognize JIS characters. <br><dt>‘<samp><span class="samp">C-SJIS</span></samp>’<dd>Recognize SJIS characters. <br><dt>‘<samp><span class="samp">C-EUCJP</span></samp>’<dd>Recognize EUCJP characters. </dl> <p>If <samp><span class="env">LANG</span></samp> is not defined, or if it has some other value, then the compiler uses <code>mblen</code> and <code>mbtowc</code> as defined by the default locale to recognize and translate multibyte characters. </dl> <p class="noindent">Some additional environment variables affect the behavior of the preprocessor. <!-- Copyright (C) 1999-2015 Free Software Foundation, Inc. --> <!-- This is part of the CPP and GCC manuals. --> <!-- For copying conditions, see the file gcc.texi. --> <!-- --> <!-- Environment variables affecting the preprocessor --> <!-- --> <!-- If this file is included with the flag ``cppmanual'' set, it is --> <!-- formatted for inclusion in the CPP manual; otherwise the main GCC manual. --> <dl> <dt><samp><span class="env">CPATH</span></samp><a name="index-CPATH-2849"></a><dt><samp><span class="env">C_INCLUDE_PATH</span></samp><a name="index-C_005fINCLUDE_005fPATH-2850"></a><dt><samp><span class="env">CPLUS_INCLUDE_PATH</span></samp><a name="index-CPLUS_005fINCLUDE_005fPATH-2851"></a><dt><samp><span class="env">OBJC_INCLUDE_PATH</span></samp><a name="index-OBJC_005fINCLUDE_005fPATH-2852"></a><dd><!-- Commented out until ObjC++ is part of GCC: --> <!-- @itemx OBJCPLUS_INCLUDE_PATH --> Each variable's value is a list of directories separated by a special character, much like <samp><span class="env">PATH</span></samp>, in which to look for header files. The special character, <code>PATH_SEPARATOR</code>, 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. <p><samp><span class="env">CPATH</span></samp> specifies a list of directories to be searched as if specified with <samp><span class="option">-I</span></samp>, but after any paths given with <samp><span class="option">-I</span></samp> options on the command line. This environment variable is used regardless of which language is being preprocessed. <p>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 <samp><span class="option">-isystem</span></samp>, but after any paths given with <samp><span class="option">-isystem</span></samp> options on the command line. <p>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 <samp><span class="env">CPATH</span></samp> is <code>:/special/include</code>, that has the same effect as ‘<samp><span class="samp">-I. -I/special/include<!-- /@w --></span></samp>’. <!-- man end --> <!-- man begin ENVIRONMENT --> <br><dt><samp><span class="env">DEPENDENCIES_OUTPUT</span></samp><a name="index-DEPENDENCIES_005fOUTPUT-2853"></a><dd><a name="index-dependencies-for-make-as-output-2854"></a>If this variable is set, its value specifies how to output dependencies for Make based on the non-system header files processed by the compiler. System header files are ignored in the dependency output. <p>The value of <samp><span class="env">DEPENDENCIES_OUTPUT</span></samp> 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 ‘<samp><var>file</var> <var>target</var></samp>’, in which case the rules are written to file <var>file</var> using <var>target</var> as the target name. <p>In other words, this environment variable is equivalent to combining the options <samp><span class="option">-MM</span></samp> and <samp><span class="option">-MF</span></samp> (see <a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>), with an optional <samp><span class="option">-MT</span></samp> switch too. <br><dt><samp><span class="env">SUNPRO_DEPENDENCIES</span></samp><a name="index-SUNPRO_005fDEPENDENCIES-2855"></a><dd><a name="index-dependencies-for-make-as-output-2856"></a>This variable is the same as <samp><span class="env">DEPENDENCIES_OUTPUT</span></samp> (see above), except that system header files are not ignored, so it implies <samp><span class="option">-M</span></samp> rather than <samp><span class="option">-MM</span></samp>. However, the dependence on the main input file is omitted. See <a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>. </dl> <!-- man end --> </body></html>