📄 environment-variables.html
字号:
<html lang="en"><head><title>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.6"><!--Copyright © 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. <p>Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.2 orany later version published by the Free Software Foundation; with theInvariant Sections being "GNU General Public License" and "FundingFree Software", the Front-Cover texts being (a) (see below), and withthe Back-Cover Texts being (b) (see below). A copy of the license isincluded in the section entitled "GNU Free Documentation License". <p>(a) The FSF's Front-Cover Text is: <p>A GNU Manual <p>(b) The FSF's Back-Cover Text is: <p>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 }--></style></head><body><div class="node"><p>Node: <a name="Environment%20Variables">Environment Variables</a>,Next: <a rel="next" accesskey="n" href="Precompiled-Headers.html#Precompiled%20Headers">Precompiled Headers</a>,Previous: <a rel="previous" accesskey="p" href="Code-Gen-Options.html#Code%20Gen%20Options">Code Gen Options</a>,Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking%20GCC">Invoking GCC</a><hr><br></div><h3 class="section">Environment Variables Affecting GCC</h3><p>This section describes several environment variables that affect how GCCoperates. Some of them work by specifying directories or prefixes to usewhen searching for various kinds of files. Some are used to specify otheraspects of the compilation environment. <p>Note that you can also specify places to search using options such as<code>-B</code>, <code>-I</code> and <code>-L</code> (see <a href="Directory-Options.html#Directory%20Options">Directory Options</a>). Thesetake precedence over places specified using environment variables, whichin turn take precedence over those specified by the configuration of GCC. See <a href="../gccint/Driver.html#Driver">Controlling the Compilation Driver <code>gcc</code></a>. <dl><dt><code>LANG</code> <dd><dt><code>LC_CTYPE</code> <dd><dt><code>LC_MESSAGES</code> <dd><dt><code>LC_ALL</code> <dd>These environment variables control the way that GCC useslocalization information that allow GCC to work with differentnational conventions. GCC inspects the locale categories<code>LC_CTYPE</code> and <code>LC_MESSAGES</code> if it has been configured to doso. These locale categories can be set to any value supported by yourinstallation. A typical value is <code>en_UK</code> for English in the UnitedKingdom. <p>The <code>LC_CTYPE</code> environment variable specifies characterclassification. GCC uses it to determine the character boundaries ina string; this is needed for some multibyte encodings that contain quoteand escape characters that would otherwise be interpreted as a stringend or escape. <p>The <code>LC_MESSAGES</code> environment variable specifies the language touse in diagnostic messages. <p>If the <code>LC_ALL</code> environment variable is set, it overrides the valueof <code>LC_CTYPE</code> and <code>LC_MESSAGES</code>; otherwise, <code>LC_CTYPE</code>and <code>LC_MESSAGES</code> default to the value of the <code>LANG</code>environment variable. If none of these variables are set, GCCdefaults to traditional C English behavior. <br><dt><code>TMPDIR</code> <dd>If <code>TMPDIR</code> is set, it specifies the directory to use for temporaryfiles. GCC uses temporary files to hold the output of one stage ofcompilation which is to be used as input to the next stage: for example,the output of the preprocessor, which is the input to the compilerproper. <br><dt><code>GCC_EXEC_PREFIX</code> <dd>If <code>GCC_EXEC_PREFIX</code> is set, it specifies a prefix to use in thenames of the subprograms executed by the compiler. No slash is addedwhen this prefix is combined with the name of a subprogram, but you canspecify a prefix that ends with a slash if you wish. <p>If <code>GCC_EXEC_PREFIX</code> is not set, GCC will attempt to figure outan appropriate prefix to use based on the pathname it was invoked with. <p>If GCC cannot find the subprogram using the specified prefix, ittries looking in the usual places for the subprogram. <p>The default value of <code>GCC_EXEC_PREFIX</code> is<code></code><var>prefix</var><code>/lib/gcc/</code> where <var>prefix</var> is the valueof <code>prefix</code> when you ran the <code>configure</code> script. <p>Other prefixes specified with <code>-B</code> take precedence over this prefix. <p>This prefix is also used for finding files such as <code>crt0.o</code> that areused for linking. <p>In addition, the prefix is used in an unusual way in finding thedirectories to search for header files. For each of the standarddirectories whose name normally begins with <code>/usr/local/lib/gcc</code>(more precisely, with the value of <code>GCC_INCLUDE_DIR</code>), GCC triesreplacing that beginning with the specified prefix to produce analternate directory name. Thus, with <code>-Bfoo/</code>, GCC will search<code>foo/bar</code> where it would normally search <code>/usr/local/lib/bar</code>. These alternate directories are searched first; the standard directoriescome next. <br><dt><code>COMPILER_PATH</code> <dd>The value of <code>COMPILER_PATH</code> is a colon-separated list ofdirectories, much like <code>PATH</code>. GCC tries the directories thusspecified when searching for subprograms, if it can't find thesubprograms using <code>GCC_EXEC_PREFIX</code>. <br><dt><code>LIBRARY_PATH</code> <dd>The value of <code>LIBRARY_PATH</code> is a colon-separated list ofdirectories, much like <code>PATH</code>. When configured as a native compiler,GCC tries the directories thus specified when searching for speciallinker files, if it can't find them using <code>GCC_EXEC_PREFIX</code>. Linkingusing GCC also uses these directories when searching for ordinarylibraries for the <code>-l</code> option (but directories specified with<code>-L</code> come first). <br><dt><code>LANG</code> <dd>This variable is used to pass locale information to the compiler. One way inwhich this information is used is to determine the character set to be usedwhen 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 <code>LANG</code> are recognized: <dl><dt><code>C-JIS</code> <dd>Recognize JIS characters. <br><dt><code>C-SJIS</code> <dd>Recognize SJIS characters. <br><dt><code>C-EUCJP</code> <dd>Recognize EUCJP characters. </dl> <p>If <code>LANG</code> is not defined, or if it has some other value, then thecompiler will use mblen and mbtowc as defined by the default locale torecognize and translate multibyte characters. </dl><p>Some additional environments variables affect the behavior of thepreprocessor. <dl><dt><code>CPATH</code> <dd><dt><code>C_INCLUDE_PATH</code> <dd><dt><code>CPLUS_INCLUDE_PATH</code> <dd><dt><code>OBJC_INCLUDE_PATH</code> <dd>Each variable's value is a list of directories separated by a specialcharacter, much like <code>PATH</code>, in which to look for header files. The special character, <code>PATH_SEPARATOR</code>, is target-dependent anddetermined at GCC build time. For Microsoft Windows-based targets it is asemicolon, and for almost all other targets it is a colon. <p><code>CPATH</code> specifies a list of directories to be searched as ifspecified with <code>-I</code>, but after any paths given with <code>-I</code>options on the command line. This environment variable is usedregardless of which language is being preprocessed. <p>The remaining environment variables apply only when preprocessing theparticular language indicated. Each specifies a list of directoriesto be searched as if specified with <code>-isystem</code>, but after anypaths given with <code>-isystem</code> options on the command line. <p>In all these variables, an empty element instructs the compiler tosearch its current working directory. Empty elements can appear at thebeginning or end of a path. For instance, if the value of<code>CPATH</code> is <code>:/special/include</code>, that has the sameeffect as <code>-I. -I/special/include</code>. <br><dt><code>DEPENDENCIES_OUTPUT</code> <dd>If this variable is set, its value specifies how to outputdependencies for Make based on the non-system header files processedby the compiler. System header files are ignored in the dependencyoutput. <p>The value of <code>DEPENDENCIES_OUTPUT</code> can be just a file name, inwhich case the Make rules are written to that file, guessing the targetname from the source file name. Or the value can have the form<code></code><var>file</var><code> </code><var>target</var><code></code>, in which case the rules are written tofile <var>file</var> using <var>target</var> as the target name. <p>In other words, this environment variable is equivalent to combiningthe options <code>-MM</code> and <code>-MF</code>(see <a href="Preprocessor-Options.html#Preprocessor%20Options">Preprocessor Options</a>),with an optional <code>-MT</code> switch too. <br><dt><code>SUNPRO_DEPENDENCIES</code> <dd>This variable is the same as <code>DEPENDENCIES_OUTPUT</code> (see above),except that system header files are not ignored, so it implies<code>-M</code> rather than <code>-MM</code>. However, the dependence on themain input file is omitted. See <a href="Preprocessor-Options.html#Preprocessor%20Options">Preprocessor Options</a>. </dl> </body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -