1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<div class="section-level-extent" id="Directory-Options"> <div class="nav-panel"> <p> Next: <a href="code-gen-options" accesskey="n" rel="next">Options for Code Generation Conventions</a>, Previous: <a href="link-options" accesskey="p" rel="prev">Options for Linking</a>, Up: <a href="invoking-gcc" accesskey="u" rel="up">GCC Command Options</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div> <h1 class="section" id="Options-for-Directory-Search"><span>3.16 Options for Directory Search<a class="copiable-link" href="#Options-for-Directory-Search"> ¶</a></span></h1> <p>These options specify directories to search for header files, for libraries and for parts of the compiler: </p> <dl class="table"> <dt>
<span><code class="code">-I <var class="var">dir</var></code><a class="copiable-link" href="#index-I"> ¶</a></span>
</dt> <dt><code class="code">-iquote <var class="var">dir</var></code></dt> <dt><code class="code">-isystem <var class="var">dir</var></code></dt> <dt><code class="code">-idirafter <var class="var">dir</var></code></dt> <dd>
<p>Add the directory <var class="var">dir</var> to the list of directories to be searched for header files during preprocessing. If <var class="var">dir</var> begins with ‘<samp class="samp">=</samp>’ or <code class="code">$SYSROOT</code>, then the ‘<samp class="samp">=</samp>’ or <code class="code">$SYSROOT</code> is replaced by the sysroot prefix; see <samp class="option">--sysroot</samp> and <samp class="option">-isysroot</samp>. </p> <p>Directories specified with <samp class="option">-iquote</samp> apply only to the quote form of the directive, <code class="code">#include "<var class="var">file</var>"</code>. Directories specified with <samp class="option">-I</samp>, <samp class="option">-isystem</samp>, or <samp class="option">-idirafter</samp> apply to lookup for both the <code class="code">#include "<var class="var">file</var>"</code> and <code class="code">#include <<var class="var">file</var>></code> directives. </p> <p>You can specify any number or combination of these options on the command line to search for header files in several directories. The lookup order is as follows: </p> <ol class="enumerate"> <li> For the quote form of the include directive, the directory of the current file is searched first. </li>
<li> For the quote form of the include directive, the directories specified by <samp class="option">-iquote</samp> options are searched in left-to-right order, as they appear on the command line. </li>
<li> Directories specified with <samp class="option">-I</samp> options are scanned in left-to-right order. </li>
<li> Directories specified with <samp class="option">-isystem</samp> options are scanned in left-to-right order. </li>
<li> Standard system directories are scanned. </li>
<li> Directories specified with <samp class="option">-idirafter</samp> options are scanned in left-to-right order. </li>
</ol> <p>You can use <samp class="option">-I</samp> to override a system header file, substituting your own version, since these directories are searched before the standard system header file directories. However, you should not use this option to add directories that contain vendor-supplied system header files; use <samp class="option">-isystem</samp> for that. </p> <p>The <samp class="option">-isystem</samp> and <samp class="option">-idirafter</samp> options also mark the directory as a system directory, so that it gets the same special treatment that is applied to the standard system directories. </p> <p>If a standard system include directory, or a directory specified with <samp class="option">-isystem</samp>, is also specified with <samp class="option">-I</samp>, the <samp class="option">-I</samp> option is ignored. The directory is still searched but as a system directory at its normal position in the system include chain. This is to ensure that GCC’s procedure to fix buggy system headers and the ordering for the <code class="code">#include_next</code> directive are not inadvertently changed. If you really need to change the search order for system directories, use the <samp class="option">-nostdinc</samp> and/or <samp class="option">-isystem</samp> options. </p> </dd> <dt>
<span><code class="code">-I-</code><a class="copiable-link" href="#index-I-"> ¶</a></span>
</dt> <dd>
<p>Split the include path. This option has been deprecated. Please use <samp class="option">-iquote</samp> instead for <samp class="option">-I</samp> directories before the <samp class="option">-I-</samp> and remove the <samp class="option">-I-</samp> option. </p> <p>Any directories specified with <samp class="option">-I</samp> options before <samp class="option">-I-</samp> are searched only for headers requested with <code class="code">#include "<var class="var">file</var>"</code>; they are not searched for <code class="code">#include <<var class="var">file</var>></code>. If additional directories are specified with <samp class="option">-I</samp> options after the <samp class="option">-I-</samp>, those directories are searched for all ‘<samp class="samp">#include</samp>’ directives. </p> <p>In addition, <samp class="option">-I-</samp> inhibits the use of the directory of the current file directory as the first search directory for <code class="code">#include "<var class="var">file</var>"</code>. There is no way to override this effect of <samp class="option">-I-</samp>. </p> </dd> <dt>
<span><code class="code">-iprefix <var class="var">prefix</var></code><a class="copiable-link" href="#index-iprefix"> ¶</a></span>
</dt> <dd>
<p>Specify <var class="var">prefix</var> as the prefix for subsequent <samp class="option">-iwithprefix</samp> options. If the prefix represents a directory, you should include the final ‘<samp class="samp">/</samp>’. </p> </dd> <dt>
<span><code class="code">-iwithprefix <var class="var">dir</var></code><a class="copiable-link" href="#index-iwithprefix"> ¶</a></span>
</dt> <dt><code class="code">-iwithprefixbefore <var class="var">dir</var></code></dt> <dd>
<p>Append <var class="var">dir</var> to the prefix specified previously with <samp class="option">-iprefix</samp>, and add the resulting directory to the include search path. <samp class="option">-iwithprefixbefore</samp> puts it in the same place <samp class="option">-I</samp> would; <samp class="option">-iwithprefix</samp> puts it where <samp class="option">-idirafter</samp> would. </p> </dd> <dt>
<span><code class="code">-isysroot <var class="var">dir</var></code><a class="copiable-link" href="#index-isysroot"> ¶</a></span>
</dt> <dd>
<p>This option is like the <samp class="option">--sysroot</samp> option, but applies only to header files (except for Darwin targets, where it applies to both header files and libraries). See the <samp class="option">--sysroot</samp> option for more information. </p> </dd> <dt>
<span><code class="code">-imultilib <var class="var">dir</var></code><a class="copiable-link" href="#index-imultilib"> ¶</a></span>
</dt> <dd>
<p>Use <var class="var">dir</var> as a subdirectory of the directory containing target-specific C++ headers. </p> </dd> <dt>
<span><code class="code">-nostdinc</code><a class="copiable-link" href="#index-nostdinc"> ¶</a></span>
</dt> <dd>
<p>Do not search the standard system directories for header files. Only the directories explicitly specified with <samp class="option">-I</samp>, <samp class="option">-iquote</samp>, <samp class="option">-isystem</samp>, and/or <samp class="option">-idirafter</samp> options (and the directory of the current file, if appropriate) are searched. </p> </dd> <dt>
<span><code class="code">-nostdinc++</code><a class="copiable-link" href="#index-nostdinc_002b_002b-1"> ¶</a></span>
</dt> <dd>
<p>Do not search for header files in the C++-specific standard directories, but do still search the other standard directories. (This option is used when building the C++ library.) </p> </dd> <dt>
<span><code class="code">-iplugindir=<var class="var">dir</var></code><a class="copiable-link" href="#index-iplugindir_003d"> ¶</a></span>
</dt> <dd>
<p>Set the directory to search for plugins that are passed by <samp class="option">-fplugin=<var class="var">name</var></samp> instead of <samp class="option">-fplugin=<var class="var">path</var>/<var class="var">name</var>.so</samp>. This option is not meant to be used by the user, but only passed by the driver. </p> </dd> <dt>
<span><code class="code">-L<var class="var">dir</var></code><a class="copiable-link" href="#index-L"> ¶</a></span>
</dt> <dd>
<p>Add directory <var class="var">dir</var> to the list of directories to be searched for <samp class="option">-l</samp>. </p> </dd> <dt>
<span><code class="code">-B<var class="var">prefix</var></code><a class="copiable-link" href="#index-B"> ¶</a></span>
</dt> <dd>
<p>This option specifies where to find the executables, libraries, include files, and data files of the compiler itself. </p> <p>The compiler driver program runs one or more of the subprograms <code class="command">cpp</code>, <code class="command">cc1</code>, <code class="command">as</code> and <code class="command">ld</code>. It tries <var class="var">prefix</var> as a prefix for each program it tries to run, both with and without ‘<samp class="samp"><var class="var">machine</var>/<var class="var">version</var>/</samp>’ for the corresponding target machine and compiler version. </p> <p>For each subprogram to be run, the compiler driver first tries the <samp class="option">-B</samp> prefix, if any. If that name is not found, or if <samp class="option">-B</samp> is not specified, the driver tries two standard prefixes, <samp class="file">/usr/lib/gcc/</samp> and <samp class="file">/usr/local/lib/gcc/</samp>. If neither of those results in a file name that is found, the unmodified program name is searched for using the directories specified in your <code class="env">PATH</code> environment variable. </p> <p>The compiler checks to see if the path provided by <samp class="option">-B</samp> refers to a directory, and if necessary it adds a directory separator character at the end of the path. </p> <p><samp class="option">-B</samp> prefixes that effectively specify directory names also apply to libraries in the linker, because the compiler translates these options into <samp class="option">-L</samp> options for the linker. They also apply to include files in the preprocessor, because the compiler translates these options into <samp class="option">-isystem</samp> options for the preprocessor. In this case, the compiler appends ‘<samp class="samp">include</samp>’ to the prefix. </p> <p>The runtime support file <samp class="file">libgcc.a</samp> can also be searched for using the <samp class="option">-B</samp> prefix, if needed. If it is not found there, the two standard prefixes above are tried, and that is all. The file is left out of the link if it is not found by those means. </p> <p>Another way to specify a prefix much like the <samp class="option">-B</samp> prefix is to use the environment variable <code class="env">GCC_EXEC_PREFIX</code>. See <a class="xref" href="environment-variables">Environment Variables Affecting GCC</a>. </p> <p>As a special kludge, if the path provided by <samp class="option">-B</samp> is <samp class="file">[dir/]stage<var class="var">N</var>/</samp>, where <var class="var">N</var> is a number in the range 0 to 9, then it is replaced by <samp class="file">[dir/]include</samp>. This is to help with boot-strapping the compiler. </p> </dd> <dt>
<span><code class="code">-no-canonical-prefixes</code><a class="copiable-link" href="#index-no-canonical-prefixes"> ¶</a></span>
</dt> <dd>
<p>Do not expand any symbolic links, resolve references to ‘<samp class="samp">/../</samp>’ or ‘<samp class="samp">/./</samp>’, or make the path absolute when generating a relative prefix. </p> </dd> <dt>
<span><code class="code">--sysroot=<var class="var">dir</var></code><a class="copiable-link" href="#index-sysroot"> ¶</a></span>
</dt> <dd>
<p>Use <var class="var">dir</var> as the logical root directory for headers and libraries. For example, if the compiler normally searches for headers in <samp class="file">/usr/include</samp> and libraries in <samp class="file">/usr/lib</samp>, it instead searches <samp class="file"><var class="var">dir</var>/usr/include</samp> and <samp class="file"><var class="var">dir</var>/usr/lib</samp>. </p> <p>If you use both this option and the <samp class="option">-isysroot</samp> option, then the <samp class="option">--sysroot</samp> option applies to libraries, but the <samp class="option">-isysroot</samp> option applies to header files. </p> <p>The GNU linker (beginning with version 2.16) has the necessary support for this option. If your linker does not support this option, the header file aspect of <samp class="option">--sysroot</samp> still works, but the library aspect does not. </p> </dd> <dt>
<span><code class="code">--no-sysroot-suffix</code><a class="copiable-link" href="#index-no-sysroot-suffix"> ¶</a></span>
</dt> <dd>
<p>For some targets, a suffix is added to the root directory specified with <samp class="option">--sysroot</samp>, depending on the other options used, so that headers may for example be found in <samp class="file"><var class="var">dir</var>/<var class="var">suffix</var>/usr/include</samp> instead of <samp class="file"><var class="var">dir</var>/usr/include</samp>. This option disables the addition of such a suffix. </p> </dd> </dl> </div> <div class="nav-panel"> <p> Next: <a href="code-gen-options">Options for Code Generation Conventions</a>, Previous: <a href="link-options">Options for Linking</a>, Up: <a href="invoking-gcc">GCC Command Options</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div><div class="_attribution">
<p class="_attribution-p">
© Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br>
<a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Directory-Options.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Directory-Options.html</a>
</p>
</div>
|