Options for Directory Search

Previous GCC Command-Line Options Next

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

-Idir
Add the directory dir 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 '-isystem' for that). If you use more than one '-I' option, the directories are scanned in left-to-right order; the standard system directories come after.

If a standard system include directory, or a directory specified with '-isystem', is also specified with '-I', the '-I' option will be ignored. The directory will still be 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 include_next directive are not inadvertently changed. If you really need to change the search order for system directories, use the '-nostdinc' and/or '-isystem' options.

-I-
Any directories you specify with '-I' options before the '-I-' option are searched only for the case of #include "file"; they are not searched for #include <file>.

If additional directories are specified with '-I' options after the '-I-', these directories are searched for all #include directives. (Ordinarily all '-I' directories are used this way.)

In addition, the '-I-' option inhibits the use of the current directory (where the current input file came from) as the first search directory for #include "file". There is no way to override this effect of '-I-'. With '-I.' you can specify searching the directory which was current when the compiler was invoked. That is not exactly the same as what the preprocessor does by default, but it is often satisfactory.

'-I-' does not inhibit the use of the standard system directories for header files. Thus, '-I-' and '-nostdinc' are independent.

-Ldir
Add directory dir to the list of directories to be searched for '-l'.

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

The compiler will check to see if the path provided by the '-B' refers to a directory, and if necessary it will add a directory separator character at the end of the path.

Another way to specify a prefix much like the '-B' prefix is to use the environment variable GCC_EXEC_PREFIX. See Environment Variables.

-specs=file
Process file after the compiler reads in the standard specs file, in order to override the defaults that the gcc driver program uses when determining what switches to pass to the individual programs. This does not work in TIGCC.