⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 environment-variables.html

📁 gcc手册
💻 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.3">

<link href="http://www.gnu.org/software/texinfo/" rel="generator-home">

<!--

Copyright &copy; 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,

1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.



   <p>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 "GNU General Public License" and "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".



   <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.-->

</head>

<body>

<div class="node">

<p>

Node:<a name="Environment%20Variables">Environment Variables</a>,

Next:<a rel="next" accesskey="n" href="Running-Protoize.html#Running%20Protoize">Running Protoize</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 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

<code>-B</code>, <code>-I</code> and <code>-L</code> (see <a href="Directory-Options.html#Directory%20Options">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 <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 uses

localization information that allow GCC to work with different

national conventions.  GCC inspects the locale categories

<code>LC_CTYPE</code> and <code>LC_MESSAGES</code> 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 <code>en_UK</code> for English in the United

Kingdom.



     <p>The <code>LC_CTYPE</code> 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 <code>LC_MESSAGES</code> environment variable specifies the language to

use in diagnostic messages.



     <p>If the <code>LC_ALL</code> environment variable is set, it overrides the value

of <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, GCC

defaults to traditional C English behavior.



     <br><dt><code>TMPDIR</code>

     <dd>If <code>TMPDIR</code> 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><code>GCC_EXEC_PREFIX</code>

     <dd>If <code>GCC_EXEC_PREFIX</code> 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 <code>GCC_EXEC_PREFIX</code> 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 <code>GCC_EXEC_PREFIX</code> is

<code></code><var>prefix</var><code>/lib/gcc-lib/</code> where <var>prefix</var> is the value

of <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 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 <code>/usr/local/lib/gcc-lib</code>

(more precisely, with the value of <code>GCC_INCLUDE_DIR</code>), GCC tries

replacing that beginning with the specified prefix to produce an

alternate 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 directories

come next.



     <br><dt><code>COMPILER_PATH</code>

     <dd>The value of <code>COMPILER_PATH</code> is a colon-separated list of

directories, much like <code>PATH</code>.  GCC tries the directories thus

specified when searching for subprograms, if it can't find the

subprograms 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 of

directories, much like <code>PATH</code>.  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 <code>GCC_EXEC_PREFIX</code>.  Linking

using GCC also uses these directories when searching for ordinary

libraries 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 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 <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 the

compiler will use mblen and mbtowc as defined by the default locale to

recognize and translate multibyte characters. 

</dl>



<p>Some additional environments variables affect the behavior of the

preprocessor.



     <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 special

character, much like <code>PATH</code>, in which to look for header files. 

The special character, <code>PATH_SEPARATOR</code>, is target-dependent and

determined at GCC build time.  For Windows-based targets it is a

semicolon, and for almost all other targets it is a colon.



     <p><code>CPATH</code> specifies a list of directories to be searched as if

specified with <code>-I</code>, but after any paths given with <code>-I</code>

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 <code>-isystem</code>, but after any

paths given with <code>-isystem</code> 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

<code>CPATH</code> is <code>:/special/include</code>, that has the same

effect as <code>-I.&nbsp;-I/special/include</code>.



     <br><dt><code>DEPENDENCIES_OUTPUT</code>

     <dd>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 <code>DEPENDENCIES_OUTPUT</code> 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

<code></code><var>file</var><code> </code><var>target</var><code></code>, 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 <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 the

main 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 + -