<html lang="en"> <head> <title>Directory Options - 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="Link-Options.html#Link-Options" title="Link Options"> <link rel="next" href="Spec-Files.html#Spec-Files" title="Spec Files"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- Copyright (C) 1988-2015 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.3 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> </head> <body> <div class="node"> <a name="Directory-Options"></a> <p> Next: <a rel="next" accesskey="n" href="Spec-Files.html#Spec-Files">Spec Files</a>, Previous: <a rel="previous" accesskey="p" href="Link-Options.html#Link-Options">Link Options</a>, Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a> <hr> </div> <h3 class="section">3.14 Options for Directory Search</h3> <p><a name="index-directory-options-1243"></a><a name="index-options_002c-directory-search-1244"></a><a name="index-search-path-1245"></a> These options specify directories to search for header files, for libraries and for parts of the compiler: <dl> <dt><code>-I</code><var>dir</var><dd><a name="index-I-1246"></a>Add the directory <var>dir</var> to the head of the list of directories to be searched for header files. This can be used to override a system header file, substituting your own version, since these directories are searched before the system header file directories. However, you should not use this option to add directories that contain vendor-supplied system header files (use <samp><span class="option">-isystem</span></samp> for that). If you use more than one <samp><span class="option">-I</span></samp> option, the directories are scanned in left-to-right order; the standard system directories come after. <p>If a standard system include directory, or a directory specified with <samp><span class="option">-isystem</span></samp>, is also specified with <samp><span class="option">-I</span></samp>, the <samp><span class="option">-I</span></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>include_next</code> directive are not inadvertently changed. If you really need to change the search order for system directories, use the <samp><span class="option">-nostdinc</span></samp> and/or <samp><span class="option">-isystem</span></samp> options. <br><dt><code>-iplugindir=</code><var>dir</var><dd><a name="index-iplugindir_003d-1247"></a>Set the directory to search for plugins that are passed by <samp><span class="option">-fplugin=</span><var>name</var></samp> instead of <samp><span class="option">-fplugin=</span><var>path</var><span class="option">/</span><var>name</var><span class="option">.so</span></samp>. This option is not meant to be used by the user, but only passed by the driver. <br><dt><code>-iquote</code><var>dir</var><dd><a name="index-iquote-1248"></a>Add the directory <var>dir</var> to the head of the list of directories to be searched for header files only for the case of <code>#include "</code><var>file</var><code>"</code>; they are not searched for <code>#include <</code><var>file</var><code>></code>, otherwise just like <samp><span class="option">-I</span></samp>. <br><dt><code>-L</code><var>dir</var><dd><a name="index-L-1249"></a>Add directory <var>dir</var> to the list of directories to be searched for <samp><span class="option">-l</span></samp>. <br><dt><code>-B</code><var>prefix</var><dd><a name="index-B-1250"></a>This option specifies where to find the executables, libraries, include files, and data files of the compiler itself. <p>The compiler driver program runs one or more of the subprograms <samp><span class="command">cpp</span></samp>, <samp><span class="command">cc1</span></samp>, <samp><span class="command">as</span></samp> and <samp><span class="command">ld</span></samp>. It tries <var>prefix</var> as a prefix for each program it tries to run, both with and without ‘<samp><var>machine</var><span class="samp">/</span><var>version</var><span class="samp">/</span></samp>’ (see <a href="Target-Options.html#Target-Options">Target Options</a>). <p>For each subprogram to be run, the compiler driver first tries the <samp><span class="option">-B</span></samp> prefix, if any. If that name is not found, or if <samp><span class="option">-B</span></samp> is not specified, the driver tries two standard prefixes, <samp><span class="file">/usr/lib/gcc/</span></samp> and <samp><span class="file">/usr/local/lib/gcc/</span></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 <samp><span class="env">PATH</span></samp> environment variable. <p>The compiler checks to see if the path provided by <samp><span class="option">-B</span></samp> refers to a directory, and if necessary it adds a directory separator character at the end of the path. <p><samp><span class="option">-B</span></samp> prefixes that effectively specify directory names also apply to libraries in the linker, because the compiler translates these options into <samp><span class="option">-L</span></samp> options for the linker. They also apply to include files in the preprocessor, because the compiler translates these options into <samp><span class="option">-isystem</span></samp> options for the preprocessor. In this case, the compiler appends ‘<samp><span class="samp">include</span></samp>’ to the prefix. <p>The runtime support file <samp><span class="file">libgcc.a</span></samp> can also be searched for using the <samp><span class="option">-B</span></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>Another way to specify a prefix much like the <samp><span class="option">-B</span></samp> prefix is to use the environment variable <samp><span class="env">GCC_EXEC_PREFIX</span></samp>. See <a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>. <p>As a special kludge, if the path provided by <samp><span class="option">-B</span></samp> is <samp><span class="file">[dir/]stage</span><var>N</var><span class="file">/</span></samp>, where <var>N</var> is a number in the range 0 to 9, then it is replaced by <samp><span class="file">[dir/]include</span></samp>. This is to help with boot-strapping the compiler. <br><dt><code>-specs=</code><var>file</var><dd><a name="index-specs-1251"></a>Process <var>file</var> after the compiler reads in the standard <samp><span class="file">specs</span></samp> file, in order to override the defaults which the <samp><span class="command">gcc</span></samp> driver program uses when determining what switches to pass to <samp><span class="command">cc1</span></samp>, <samp><span class="command">cc1plus</span></samp>, <samp><span class="command">as</span></samp>, <samp><span class="command">ld</span></samp>, etc. More than one <samp><span class="option">-specs=</span><var>file</var></samp> can be specified on the command line, and they are processed in order, from left to right. <br><dt><code>--sysroot=</code><var>dir</var><dd><a name="index-sysroot-1252"></a>Use <var>dir</var> as the logical root directory for headers and libraries. For example, if the compiler normally searches for headers in <samp><span class="file">/usr/include</span></samp> and libraries in <samp><span class="file">/usr/lib</span></samp>, it instead searches <samp><var>dir</var><span class="file">/usr/include</span></samp> and <samp><var>dir</var><span class="file">/usr/lib</span></samp>. <p>If you use both this option and the <samp><span class="option">-isysroot</span></samp> option, then the <samp><span class="option">--sysroot</span></samp> option applies to libraries, but the <samp><span class="option">-isysroot</span></samp> option applies to header files. <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><span class="option">--sysroot</span></samp> still works, but the library aspect does not. <br><dt><code>--no-sysroot-suffix</code><dd><a name="index-no_002dsysroot_002dsuffix-1253"></a>For some targets, a suffix is added to the root directory specified with <samp><span class="option">--sysroot</span></samp>, depending on the other options used, so that headers may for example be found in <samp><var>dir</var><span class="file">/</span><var>suffix</var><span class="file">/usr/include</span></samp> instead of <samp><var>dir</var><span class="file">/usr/include</span></samp>. This option disables the addition of such a suffix. <br><dt><code>-I-</code><dd><a name="index-I_002d-1254"></a>This option has been deprecated. Please use <samp><span class="option">-iquote</span></samp> instead for <samp><span class="option">-I</span></samp> directories before the <samp><span class="option">-I-</span></samp> and remove the <samp><span class="option">-I-</span></samp> option. Any directories you specify with <samp><span class="option">-I</span></samp> options before the <samp><span class="option">-I-</span></samp> option are searched only for the case of <code>#include "</code><var>file</var><code>"</code>; they are not searched for <code>#include <</code><var>file</var><code>></code>. <p>If additional directories are specified with <samp><span class="option">-I</span></samp> options after the <samp><span class="option">-I-</span></samp> option, these directories are searched for all <code>#include</code> directives. (Ordinarily <em>all</em> <samp><span class="option">-I</span></samp> directories are used this way.) <p>In addition, the <samp><span class="option">-I-</span></samp> option inhibits the use of the current directory (where the current input file came from) as the first search directory for <code>#include "</code><var>file</var><code>"</code>. There is no way to override this effect of <samp><span class="option">-I-</span></samp>. With <samp><span class="option">-I.</span></samp> you can specify searching the directory that is current when the compiler is invoked. That is not exactly the same as what the preprocessor does by default, but it is often satisfactory. <p><samp><span class="option">-I-</span></samp> does not inhibit the use of the standard system directories for header files. Thus, <samp><span class="option">-I-</span></samp> and <samp><span class="option">-nostdinc</span></samp> are independent. </dl> <!-- man end --> </body></html>