With the GNAT source-based library system, the compiler must be able to find source files for units that are needed by the unit being compiled. Search paths are used to guide this process.
The compiler compiles one source file whose name must be given explicitly on the command line. In other words, no searching is done for this file. To find all other source files that are needed (the most common being the specs of units), the compiler examines the following directories, in the following order:
ADA_INCLUDE_PATHenvironment variable. Construct this value exactly as the
PATHenvironment variable: a list of directory names separated by colons (semicolons when working with the NT version).
ADA_PRJ_INCLUDE_FILE is normally set by gnatmake or by the gnat
driver when project files are used. It should not normally be set
by other means.
Specifying the switch -I- inhibits the use of the directory containing the source file named in the command line. You can still have this directory on your search path, but in this case it must be explicitly requested with a -I switch.
Specifying the switch -nostdinc inhibits the search of the default location for the GNAT Run Time Library (RTL) source files.
The compiler outputs its object files and ALI files in the current
Caution: The object file can be redirected with the -o switch;
however, gcc and
gnat1 have not been coordinated on this
so the ALI file will not go to the right place. Therefore, you should
avoid using the -o switch.
Interfaces and their
children make up the GNAT RTL, together with the simple
package used in the
"Hello World" example. The sources for these units
are needed by the compiler and are kept together in one directory. Not
all of the bodies are needed, but all of the sources are kept together
anyway. In a normal installation, you need not specify these directory
names when compiling or binding. Either the environment variables or
the built-in defaults cause these files to be found.
In addition to the language-defined hierarchies (
Interfaces), the GNAT distribution provides a fourth hierarchy,
consisting of child units of
GNAT. This is a collection of generally
useful types, subprograms, etc. See the GNAT Reference Manual for
Besides simplifying access to the RTL, a major use of search paths is in compiling sources from multiple directories. This can make development environments much more flexible.