gcc: Directory Options

1 
1 3.15 Options for Directory Search
1 =================================
1 
1 These options specify directories to search for header files, for
1 libraries and for parts of the compiler:
1 
1 '-I DIR'
1 '-iquote DIR'
1 '-isystem DIR'
1 '-idirafter DIR'
1      Add the directory DIR to the list of directories to be searched for
1      header files during preprocessing.  If DIR begins with '=' or
1      '$SYSROOT', then the '=' or '$SYSROOT' is replaced by the sysroot
1      prefix; see '--sysroot' and '-isysroot'.
1 
1      Directories specified with '-iquote' apply only to the quote form
1      of the directive, '#include "FILE"'.  Directories specified with
1      '-I', '-isystem', or '-idirafter' apply to lookup for both the
1      '#include "FILE"' and '#include <FILE>' directives.
1 
1      You can specify any number or combination of these options on the
1      command line to search for header files in several directories.
1      The lookup order is as follows:
1 
1        1. For the quote form of the include directive, the directory of
1           the current file is searched first.
1 
1        2. For the quote form of the include directive, the directories
1           specified by '-iquote' options are searched in left-to-right
1           order, as they appear on the command line.
1 
1        3. Directories specified with '-I' options are scanned in
1           left-to-right order.
1 
1        4. Directories specified with '-isystem' options are scanned in
1           left-to-right order.
1 
1        5. Standard system directories are scanned.
1 
1        6. Directories specified with '-idirafter' options are scanned in
1           left-to-right order.
1 
1      You can use '-I' to override a system header file, substituting
1      your own version, since these directories are searched before the
1      standard system header file directories.  However, you should not
1      use this option to add directories that contain vendor-supplied
1      system header files; use '-isystem' for that.
1 
1      The '-isystem' and '-idirafter' options also mark the directory as
1      a system directory, so that it gets the same special treatment that
1      is applied to the standard system directories.
1 
1      If a standard system include directory, or a directory specified
1      with '-isystem', is also specified with '-I', the '-I' option is
1      ignored.  The directory is still searched but as a system directory
1      at its normal position in the system include chain.  This is to
1      ensure that GCC's procedure to fix buggy system headers and the
1      ordering for the '#include_next' directive are not inadvertently
1      changed.  If you really need to change the search order for system
1      directories, use the '-nostdinc' and/or '-isystem' options.
1 
1 '-I-'
1      Split the include path.  This option has been deprecated.  Please
1      use '-iquote' instead for '-I' directories before the '-I-' and
1      remove the '-I-' option.
1 
1      Any directories specified with '-I' options before '-I-' are
1      searched only for headers requested with '#include "FILE"'; they
1      are not searched for '#include <FILE>'.  If additional directories
1      are specified with '-I' options after the '-I-', those directories
1      are searched for all '#include' directives.
1 
1      In addition, '-I-' inhibits the use of the directory of the current
1      file directory as the first search directory for '#include "FILE"'.
1      There is no way to override this effect of '-I-'.
1 
1 '-iprefix PREFIX'
1      Specify PREFIX as the prefix for subsequent '-iwithprefix' options.
1      If the prefix represents a directory, you should include the final
1      '/'.
1 
1 '-iwithprefix DIR'
1 '-iwithprefixbefore DIR'
1      Append DIR to the prefix specified previously with '-iprefix', and
1      add the resulting directory to the include search path.
1      '-iwithprefixbefore' puts it in the same place '-I' would;
1      '-iwithprefix' puts it where '-idirafter' would.
1 
1 '-isysroot DIR'
1      This option is like the '--sysroot' option, but applies only to
1      header files (except for Darwin targets, where it applies to both
1      header files and libraries).  See the '--sysroot' option for more
1      information.
1 
1 '-imultilib DIR'
1      Use DIR as a subdirectory of the directory containing
1      target-specific C++ headers.
1 
1 '-nostdinc'
1      Do not search the standard system directories for header files.
1      Only the directories explicitly specified with '-I', '-iquote',
1      '-isystem', and/or '-idirafter' options (and the directory of the
1      current file, if appropriate) are searched.
1 
1 '-nostdinc++'
1      Do not search for header files in the C++-specific standard
1      directories, but do still search the other standard directories.
1      (This option is used when building the C++ library.)
1 
1 '-iplugindir=DIR'
1      Set the directory to search for plugins that are passed by
1      '-fplugin=NAME' instead of '-fplugin=PATH/NAME.so'.  This option is
1      not meant to be used by the user, but only passed by the driver.
1 
1 '-LDIR'
1      Add directory DIR to the list of directories to be searched for
1      '-l'.
1 
1 '-BPREFIX'
1      This option specifies where to find the executables, libraries,
1      include files, and data files of the compiler itself.
1 
1      The compiler driver program runs one or more of the subprograms
1      'cpp', 'cc1', 'as' and 'ld'.  It tries PREFIX as a prefix for each
1      program it tries to run, both with and without 'MACHINE/VERSION/'
1      for the corresponding target machine and compiler version.
1 
1      For each subprogram to be run, the compiler driver first tries the
1      '-B' prefix, if any.  If that name is not found, or if '-B' is not
1      specified, the driver tries two standard prefixes, '/usr/lib/gcc/'
1      and '/usr/local/lib/gcc/'.  If neither of those results in a file
1      name that is found, the unmodified program name is searched for
1      using the directories specified in your 'PATH' environment
1      variable.
1 
1      The compiler checks to see if the path provided by '-B' refers to a
1      directory, and if necessary it adds a directory separator character
1      at the end of the path.
1 
1      '-B' prefixes that effectively specify directory names also apply
1      to libraries in the linker, because the compiler translates these
1      options into '-L' options for the linker.  They also apply to
1      include files in the preprocessor, because the compiler translates
1      these options into '-isystem' options for the preprocessor.  In
1      this case, the compiler appends 'include' to the prefix.
1 
1      The runtime support file 'libgcc.a' can also be searched for using
1      the '-B' prefix, if needed.  If it is not found there, the two
1      standard prefixes above are tried, and that is all.  The file is
1      left out of the link if it is not found by those means.
1 
1      Another way to specify a prefix much like the '-B' prefix is to use
11      the environment variable 'GCC_EXEC_PREFIX'.  ⇒Environment
      Variables.
1 
1      As a special kludge, if the path provided by '-B' is
1      '[dir/]stageN/', where N is a number in the range 0 to 9, then it
1      is replaced by '[dir/]include'.  This is to help with
1      boot-strapping the compiler.
1 
1 '-no-canonical-prefixes'
1      Do not expand any symbolic links, resolve references to '/../' or
1      '/./', or make the path absolute when generating a relative prefix.
1 
1 '--sysroot=DIR'
1      Use DIR as the logical root directory for headers and libraries.
1      For example, if the compiler normally searches for headers in
1      '/usr/include' and libraries in '/usr/lib', it instead searches
1      'DIR/usr/include' and 'DIR/usr/lib'.
1 
1      If you use both this option and the '-isysroot' option, then the
1      '--sysroot' option applies to libraries, but the '-isysroot' option
1      applies to header files.
1 
1      The GNU linker (beginning with version 2.16) has the necessary
1      support for this option.  If your linker does not support this
1      option, the header file aspect of '--sysroot' still works, but the
1      library aspect does not.
1 
1 '--no-sysroot-suffix'
1      For some targets, a suffix is added to the root directory specified
1      with '--sysroot', depending on the other options used, so that
1      headers may for example be found in 'DIR/SUFFIX/usr/include'
1      instead of 'DIR/usr/include'.  This option disables the addition of
1      such a suffix.
1