1<html lang="en"> 2<head> 3<title>Environment Variables - Using the GNU Compiler Collection (GCC)</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Using the GNU Compiler Collection (GCC)"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC"> 9<link rel="prev" href="Code-Gen-Options.html#Code-Gen-Options" title="Code Gen Options"> 10<link rel="next" href="Precompiled-Headers.html#Precompiled-Headers" title="Precompiled Headers"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<!-- 13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 152010 Free Software Foundation, Inc. 16 17Permission is granted to copy, distribute and/or modify this document 18under the terms of the GNU Free Documentation License, Version 1.3 or 19any later version published by the Free Software Foundation; with the 20Invariant Sections being ``Funding Free Software'', the Front-Cover 21Texts being (a) (see below), and with the Back-Cover Texts being (b) 22(see below). A copy of the license is included in the section entitled 23``GNU Free Documentation License''. 24 25(a) The FSF's Front-Cover Text is: 26 27 A GNU Manual 28 29(b) The FSF's Back-Cover Text is: 30 31 You have freedom to copy and modify this GNU Manual, like GNU 32 software. Copies published by the Free Software Foundation raise 33 funds for GNU development.--> 34<meta http-equiv="Content-Style-Type" content="text/css"> 35<style type="text/css"><!-- 36 pre.display { font-family:inherit } 37 pre.format { font-family:inherit } 38 pre.smalldisplay { font-family:inherit; font-size:smaller } 39 pre.smallformat { font-family:inherit; font-size:smaller } 40 pre.smallexample { font-size:smaller } 41 pre.smalllisp { font-size:smaller } 42 span.sc { font-variant:small-caps } 43 span.roman { font-family:serif; font-weight:normal; } 44 span.sansserif { font-family:sans-serif; font-weight:normal; } 45--></style> 46<link rel="stylesheet" type="text/css" href="../cs.css"> 47</head> 48<body> 49<div class="node"> 50<a name="Environment-Variables"></a> 51<p> 52Next: <a rel="next" accesskey="n" href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>, 53Previous: <a rel="previous" accesskey="p" href="Code-Gen-Options.html#Code-Gen-Options">Code Gen Options</a>, 54Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a> 55<hr> 56</div> 57 58<h3 class="section">3.19 Environment Variables Affecting GCC</h3> 59 60<p><a name="index-environment-variables-2208"></a> 61<!-- man begin ENVIRONMENT --> 62This section describes several environment variables that affect how GCC 63operates. Some of them work by specifying directories or prefixes to use 64when searching for various kinds of files. Some are used to specify other 65aspects of the compilation environment. 66 67 <p>Note that you can also specify places to search using options such as 68<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 69take precedence over places specified using environment variables, which 70in turn take precedence over those specified by the configuration of GCC. 71See <a href="../gccint/Driver.html#Driver">Controlling the Compilation Driver <samp><span class="file">gcc</span></samp></a>. 72 73 <dl> 74<dt><samp><span class="env">LANG</span></samp><dt><samp><span class="env">LC_CTYPE</span></samp><dd><!-- @itemx LC_COLLATE --> 75<dt><samp><span class="env">LC_MESSAGES</span></samp><dd><!-- @itemx LC_MONETARY --> 76<!-- @itemx LC_NUMERIC --> 77<!-- @itemx LC_TIME --> 78<dt><samp><span class="env">LC_ALL</span></samp><dd><a name="index-LANG-2209"></a><a name="index-LC_005fCTYPE-2210"></a><!-- @findex LC_COLLATE --> 79<a name="index-LC_005fMESSAGES-2211"></a><!-- @findex LC_MONETARY --> 80<!-- @findex LC_NUMERIC --> 81<!-- @findex LC_TIME --> 82<a name="index-LC_005fALL-2212"></a><a name="index-locale-2213"></a>These environment variables control the way that GCC uses 83localization information that allow GCC to work with different 84national conventions. GCC inspects the locale categories 85<samp><span class="env">LC_CTYPE</span></samp> and <samp><span class="env">LC_MESSAGES</span></samp> if it has been configured to do 86so. These locale categories can be set to any value supported by your 87installation. A typical value is ‘<samp><span class="samp">en_GB.UTF-8</span></samp>’ for English in the United 88Kingdom encoded in UTF-8. 89 90 <p>The <samp><span class="env">LC_CTYPE</span></samp> environment variable specifies character 91classification. GCC uses it to determine the character boundaries in 92a string; this is needed for some multibyte encodings that contain quote 93and escape characters that would otherwise be interpreted as a string 94end or escape. 95 96 <p>The <samp><span class="env">LC_MESSAGES</span></samp> environment variable specifies the language to 97use in diagnostic messages. 98 99 <p>If the <samp><span class="env">LC_ALL</span></samp> environment variable is set, it overrides the value 100of <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> 101and <samp><span class="env">LC_MESSAGES</span></samp> default to the value of the <samp><span class="env">LANG</span></samp> 102environment variable. If none of these variables are set, GCC 103defaults to traditional C English behavior. 104 105 <br><dt><samp><span class="env">TMPDIR</span></samp><dd><a name="index-TMPDIR-2214"></a>If <samp><span class="env">TMPDIR</span></samp> is set, it specifies the directory to use for temporary 106files. GCC uses temporary files to hold the output of one stage of 107compilation which is to be used as input to the next stage: for example, 108the output of the preprocessor, which is the input to the compiler 109proper. 110 111 <br><dt><samp><span class="env">GCC_EXEC_PREFIX</span></samp><dd><a name="index-GCC_005fEXEC_005fPREFIX-2215"></a>If <samp><span class="env">GCC_EXEC_PREFIX</span></samp> is set, it specifies a prefix to use in the 112names of the subprograms executed by the compiler. No slash is added 113when this prefix is combined with the name of a subprogram, but you can 114specify a prefix that ends with a slash if you wish. 115 116 <p>If <samp><span class="env">GCC_EXEC_PREFIX</span></samp> is not set, GCC will attempt to figure out 117an appropriate prefix to use based on the pathname it was invoked with. 118 119 <p>If GCC cannot find the subprogram using the specified prefix, it 120tries looking in the usual places for the subprogram. 121 122 <p>The default value of <samp><span class="env">GCC_EXEC_PREFIX</span></samp> is 123<samp><var>prefix</var><span class="file">/lib/gcc/</span></samp> where <var>prefix</var> is the prefix to 124the installed compiler. In many cases <var>prefix</var> is the value 125of <code>prefix</code> when you ran the <samp><span class="file">configure</span></samp> script. 126 127 <p>Other prefixes specified with <samp><span class="option">-B</span></samp> take precedence over this prefix. 128 129 <p>This prefix is also used for finding files such as <samp><span class="file">crt0.o</span></samp> that are 130used for linking. 131 132 <p>In addition, the prefix is used in an unusual way in finding the 133directories to search for header files. For each of the standard 134directories whose name normally begins with ‘<samp><span class="samp">/usr/local/lib/gcc</span></samp>’ 135(more precisely, with the value of <samp><span class="env">GCC_INCLUDE_DIR</span></samp>), GCC tries 136replacing that beginning with the specified prefix to produce an 137alternate directory name. Thus, with <samp><span class="option">-Bfoo/</span></samp>, GCC will search 138<samp><span class="file">foo/bar</span></samp> where it would normally search <samp><span class="file">/usr/local/lib/bar</span></samp>. 139These alternate directories are searched first; the standard directories 140come next. If a standard directory begins with the configured 141<var>prefix</var> then the value of <var>prefix</var> is replaced by 142<samp><span class="env">GCC_EXEC_PREFIX</span></samp> when looking for header files. 143 144 <br><dt><samp><span class="env">COMPILER_PATH</span></samp><dd><a name="index-COMPILER_005fPATH-2216"></a>The value of <samp><span class="env">COMPILER_PATH</span></samp> is a colon-separated list of 145directories, much like <samp><span class="env">PATH</span></samp>. GCC tries the directories thus 146specified when searching for subprograms, if it can't find the 147subprograms using <samp><span class="env">GCC_EXEC_PREFIX</span></samp>. 148 149 <br><dt><samp><span class="env">LIBRARY_PATH</span></samp><dd><a name="index-LIBRARY_005fPATH-2217"></a>The value of <samp><span class="env">LIBRARY_PATH</span></samp> is a colon-separated list of 150directories, much like <samp><span class="env">PATH</span></samp>. When configured as a native compiler, 151GCC tries the directories thus specified when searching for special 152linker files, if it can't find them using <samp><span class="env">GCC_EXEC_PREFIX</span></samp>. Linking 153using GCC also uses these directories when searching for ordinary 154libraries for the <samp><span class="option">-l</span></samp> option (but directories specified with 155<samp><span class="option">-L</span></samp> come first). 156 157 <br><dt><samp><span class="env">LANG</span></samp><dd><a name="index-LANG-2218"></a><a name="index-locale-definition-2219"></a>This variable is used to pass locale information to the compiler. One way in 158which this information is used is to determine the character set to be used 159when character literals, string literals and comments are parsed in C and C++. 160When the compiler is configured to allow multibyte characters, 161the following values for <samp><span class="env">LANG</span></samp> are recognized: 162 163 <dl> 164<dt>‘<samp><span class="samp">C-JIS</span></samp>’<dd>Recognize JIS characters. 165<br><dt>‘<samp><span class="samp">C-SJIS</span></samp>’<dd>Recognize SJIS characters. 166<br><dt>‘<samp><span class="samp">C-EUCJP</span></samp>’<dd>Recognize EUCJP characters. 167</dl> 168 169 <p>If <samp><span class="env">LANG</span></samp> is not defined, or if it has some other value, then the 170compiler will use mblen and mbtowc as defined by the default locale to 171recognize and translate multibyte characters. 172</dl> 173 174<p class="noindent">Some additional environments variables affect the behavior of the 175preprocessor. 176 177<!-- Copyright (c) 1999, 2000, 2001, 2002, 2004 --> 178<!-- Free Software Foundation, Inc. --> 179<!-- This is part of the CPP and GCC manuals. --> 180<!-- For copying conditions, see the file gcc.texi. --> 181<!-- --> 182<!-- Environment variables affecting the preprocessor --> 183<!-- --> 184<!-- If this file is included with the flag ``cppmanual'' set, it is --> 185<!-- formatted for inclusion in the CPP manual; otherwise the main GCC manual. --> 186 <dl> 187<dt><samp><span class="env">CPATH</span></samp><a name="index-CPATH-2220"></a><dt><samp><span class="env">C_INCLUDE_PATH</span></samp><a name="index-C_005fINCLUDE_005fPATH-2221"></a><dt><samp><span class="env">CPLUS_INCLUDE_PATH</span></samp><a name="index-CPLUS_005fINCLUDE_005fPATH-2222"></a><dt><samp><span class="env">OBJC_INCLUDE_PATH</span></samp><a name="index-OBJC_005fINCLUDE_005fPATH-2223"></a><dd><!-- Commented out until ObjC++ is part of GCC: --> 188<!-- @itemx OBJCPLUS_INCLUDE_PATH --> 189Each variable's value is a list of directories separated by a special 190character, much like <samp><span class="env">PATH</span></samp>, in which to look for header files. 191The special character, <code>PATH_SEPARATOR</code>, is target-dependent and 192determined at GCC build time. For Microsoft Windows-based targets it is a 193semicolon, and for almost all other targets it is a colon. 194 195 <p><samp><span class="env">CPATH</span></samp> specifies a list of directories to be searched as if 196specified with <samp><span class="option">-I</span></samp>, but after any paths given with <samp><span class="option">-I</span></samp> 197options on the command line. This environment variable is used 198regardless of which language is being preprocessed. 199 200 <p>The remaining environment variables apply only when preprocessing the 201particular language indicated. Each specifies a list of directories 202to be searched as if specified with <samp><span class="option">-isystem</span></samp>, but after any 203paths given with <samp><span class="option">-isystem</span></samp> options on the command line. 204 205 <p>In all these variables, an empty element instructs the compiler to 206search its current working directory. Empty elements can appear at the 207beginning or end of a path. For instance, if the value of 208<samp><span class="env">CPATH</span></samp> is <code>:/special/include</code>, that has the same 209effect as ‘<samp><span class="samp">-I. -I/special/include<!-- /@w --></span></samp>’. 210 211 <!-- man end --> 212 <!-- man begin ENVIRONMENT --> 213 <br><dt><samp><span class="env">DEPENDENCIES_OUTPUT</span></samp><a name="index-DEPENDENCIES_005fOUTPUT-2224"></a><dd><a name="index-dependencies-for-make-as-output-2225"></a>If this variable is set, its value specifies how to output 214dependencies for Make based on the non-system header files processed 215by the compiler. System header files are ignored in the dependency 216output. 217 218 <p>The value of <samp><span class="env">DEPENDENCIES_OUTPUT</span></samp> can be just a file name, in 219which case the Make rules are written to that file, guessing the target 220name from the source file name. Or the value can have the form 221‘<samp><var>file</var> <var>target</var></samp>’, in which case the rules are written to 222file <var>file</var> using <var>target</var> as the target name. 223 224 <p>In other words, this environment variable is equivalent to combining 225the options <samp><span class="option">-MM</span></samp> and <samp><span class="option">-MF</span></samp> 226(see <a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>), 227with an optional <samp><span class="option">-MT</span></samp> switch too. 228 229 <br><dt><samp><span class="env">SUNPRO_DEPENDENCIES</span></samp><a name="index-SUNPRO_005fDEPENDENCIES-2226"></a><dd><a name="index-dependencies-for-make-as-output-2227"></a>This variable is the same as <samp><span class="env">DEPENDENCIES_OUTPUT</span></samp> (see above), 230except that system header files are not ignored, so it implies 231<samp><span class="option">-M</span></samp> rather than <samp><span class="option">-MM</span></samp>. However, the dependence on the 232main input file is omitted. 233See <a href="Preprocessor-Options.html#Preprocessor-Options">Preprocessor Options</a>. 234</dl> 235 236<!-- man end --> 237 </body></html> 238 239