| <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, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, |
| 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, |
| 2008 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.2 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> |
| <link rel="stylesheet" type="text/css" href="../cs.css"> |
| </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-2149"></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-2150"></a><a name="index-LC_005fCTYPE-2151"></a><!-- @findex LC_COLLATE --> |
| <a name="index-LC_005fMESSAGES-2152"></a><!-- @findex LC_MONETARY --> |
| <!-- @findex LC_NUMERIC --> |
| <!-- @findex LC_TIME --> |
| <a name="index-LC_005fALL-2153"></a><a name="index-locale-2154"></a>These environment variables control the way that GCC uses |
| localization information that allow 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 would otherwise be 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-2155"></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_EXEC_PREFIX</span></samp><dd><a name="index-GCC_005fEXEC_005fPREFIX-2156"></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 will attempt to figure out |
| an appropriate prefix to use based on the pathname it was 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 will search |
| <samp><span class="file">foo/bar</span></samp> where it would normally search <samp><span class="file">/usr/local/lib/bar</span></samp>. |
| These alternate directories are searched first; the standard directories |
| come next. 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-2157"></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-2158"></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-2159"></a><a name="index-locale-definition-2160"></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 will use mblen and mbtowc as defined by the default locale to |
| recognize and translate multibyte characters. |
| </dl> |
| |
| <p class="noindent">Some additional environments variables affect the behavior of the |
| preprocessor. |
| |
| <!-- Copyright (c) 1999, 2000, 2001, 2002, 2004 --> |
| <!-- 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-2161"></a><dt><samp><span class="env">C_INCLUDE_PATH</span></samp><a name="index-C_005fINCLUDE_005fPATH-2162"></a><dt><samp><span class="env">CPLUS_INCLUDE_PATH</span></samp><a name="index-CPLUS_005fINCLUDE_005fPATH-2163"></a><dt><samp><span class="env">OBJC_INCLUDE_PATH</span></samp><a name="index-OBJC_005fINCLUDE_005fPATH-2164"></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-2165"></a><dd><a name="index-dependencies-for-make-as-output-2166"></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-2167"></a><dd><a name="index-dependencies-for-make-as-output-2168"></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> |
| |