Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:GCC Command Options   [Contents][Index]


3.17 Options for Directory Search

These options specify directories to search for header files, forlibraries and for parts of the compiler:

-Idir
-iquotedir
-isystemdir
-idirafterdir
--include-directory-after=dir
--include-directory-afterdir
--include-directory=dir
--include-directorydir

Add the directorydir to the list of directories to be searchedfor header files during preprocessing.--include-directoryis an alias for-I, while--include-directory-afteris an alias for-idirafter.Ifdir begins with ‘=’ or$SYSROOT, then the ‘=’or$SYSROOT is replaced by the sysroot prefix; see--sysroot and-isysroot.

Directories specified with-iquote apply only to the quote form of the directive,#include "file".Directories specified with-I,-isystem, or-idirafter apply to lookup for both the#include "file" and#include <file> directives.

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:

  1. For the quote form of the include directive, the directory of the currentfile is searched first.
  2. For the quote form of the include directive, the directories specifiedby-iquote options are searched in left-to-right order,as they appear on the command line.
  3. Directories specified with-I options are scanned inleft-to-right order.
  4. Directories specified with-isystem options are scanned inleft-to-right order.
  5. Standard system directories are scanned.
  6. Directories specified with-idirafter options are scanned inleft-to-right order.

You can use-I to override a system headerfile, substituting your own version, since these directories aresearched before the standard system header file directories. However, you shouldnot use this option to add directories that contain vendor-suppliedsystem header files; use-isystem for that.

The-isystem and-idirafter options also mark the directoryas a system directory, so that it gets the same special treatment thatis applied to the standard system directories.

If a standard system include directory, or a directory specified with-isystem, is also specified with-I, the-Ioption is ignored. The directory is still searched but as asystem directory at its normal position in the system include chain.This is to ensure that GCC’s procedure to fix buggy system headers andthe ordering for the#include_next directive are not inadvertentlychanged.If you really need to change the search order for system directories,use the-nostdinc and/or-isystem options.

-I-
--include-barrier

Split the include path.This option has been deprecated. Please use-iquote instead for-I directories before the-I- and remove the-I-option.

Any directories specified with-Ioptions before-I- are searched only for headers requested with#include "file"; they are not searched for#include <file>. If additional directories arespecified with-I options after the-I-, thosedirectories are searched for all ‘#include’ directives.

In addition,-I- inhibits the use of the directory of the currentfile directory as the first search directory for#include "file". There is no way to override this effect of-I-.

-iprefixprefix
--include-prefix=prefix
--include-prefixprefix

Specifyprefix as the prefix for subsequent-iwithprefixoptions. If the prefix represents a directory, you should include thefinal ‘/’.

-iwithprefixdir
-iwithprefixbeforedir
--include-with-prefix=prefix
--include-with-prefixprefix
--include-with-prefix-after=prefix
--include-with-prefix-afterprefix
--include-with-prefix-before=prefix
--include-with-prefix-beforeprefix

Appenddir to the prefix specified previously with-iprefix, and add the resulting directory to the include searchpath.-iwithprefixbefore puts it in the same place-Iwould;-iwithprefix puts it where-idirafter would.

--include-with-prefix and--include-with-prefix-after areboth aliases for-iwithprefix, while--include-with-prefix-before is an alias for-iwithprefixbefore.

-isysrootdir

This option is like the--sysroot option, but applies only toheader files (except for Darwin targets, where it applies to both headerfiles and libraries). See the--sysroot option for moreinformation.

-imultilibdir

Usedir as a subdirectory of the directory containingtarget-specific C++ headers.

-imultiarchdir

Usedir as a subdirectory of the directory containingarchitecture-specific C++ headers.

-nostdinc
--no-standard-includes

Do not search the standard system directories for header files.Only the directories explicitly specified with-I,-iquote,-isystem, and/or-idirafteroptions (and the directory of the current file, if appropriate) are searched.

-nostdinc++

Do not search for header files in the C++-specific standard directories,but do still search the other standard directories. (This option isused when building the C++ library.)

--embed-dir=dir
--embed-directory=dir
--embed-directorydir

Appenddir directory to the list of searched directories for#embed preprocessing directive or__has_embed macro.There are no default directories for#embed.

Ifdir begins with ‘=’ or$SYSROOT, then the ‘=’or$SYSROOT is replaced by the sysroot prefix; see--sysroot and-isysroot.

-iplugindir=dir

Set the directory to search for plugins that are passedby-fplugin=name instead of-fplugin=path/name.so. This option is not meantto be used by the user, but only passed by the driver.

-Ldir
--library-directory=dir
--library-directorydir

Add directorydir to the list of directories to be searchedfor-l.

-Bprefix
--prefix=prefix
--prefixprefix

This option specifies where to find the executables, libraries,include files, and data files of the compiler itself.

The compiler driver program runs one or more of the subprogramscpp,cc1,as andld. It triesprefix as a prefix for each program it tries to run, both with andwithout ‘machine/version/’ for the corresponding targetmachine and compiler version.

For each subprogram to be run, the compiler driver first tries the-B prefix, if any. If that name is not found, or if-Bis not specified, the driver tries two standard prefixes,/usr/lib/gcc/ and/usr/local/lib/gcc/. If neither ofthose results in a file name that is found, the unmodified programname is searched for using the directories specified in yourPATH environment variable.

The compiler checks to see if the path provided by-Brefers to a directory, and if necessary it adds a directoryseparator character at the end of the path.

-B prefixes that effectively specify directory names also applyto libraries in the linker, because the compiler translates theseoptions into-L options for the linker. They also apply toinclude files in the preprocessor, because the compiler translates theseoptions into-isystem options for the preprocessor. In this case,the compiler appends ‘include’ to the prefix.

The runtime support filelibgcc.a can also be searched for usingthe-B prefix, if needed. If it is not found there, the twostandard prefixes above are tried, and that is all. The file is leftout of the link if it is not found by those means.

Another way to specify a prefix much like the-B prefix is to usethe environment variableGCC_EXEC_PREFIX. SeeEnvironment Variables Affecting GCC.

As a special kludge, if the path provided by-B is[dir/]stageN/, whereN is a number in the range 0 to9, then it is replaced by[dir/]include. This is to helpwith boot-strapping the compiler.

-no-canonical-prefixes
--no-canonical-prefixes

Do not expand any symbolic links, resolve references to ‘/../’or ‘/./’, or make the path absolute when generating a relativeprefix.

--sysroot=dir
--sysrootdir

Usedir as the logical root directory for headers and libraries.For example, if the compiler normally searches for headers in/usr/include and libraries in/usr/lib, it insteadsearchesdir/usr/include anddir/usr/lib.

If you use both this option and the-isysroot option, thenthe--sysroot option applies to libraries, but the-isysroot option applies to header files.

The GNU linker (beginning with version 2.16) has the necessary supportfor this option. If your linker does not support this option, theheader file aspect of--sysroot still works, but thelibrary aspect does not.

--no-sysroot-suffix

For some targets, a suffix is added to the root directory specifiedwith--sysroot, depending on the other options used, so thatheaders may for example be found indir/suffix/usr/include instead ofdir/usr/include. This option disables the addition ofsuch a suffix.


Next:Options for use with Picolibc, Previous:Options for Linking, Up:GCC Command Options   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp