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:
-Iswitch given on the
gcccommand line, in the order given.
ADA_PRJ_INCLUDE_FILEis normally set by gnatmake or by the gnat driver when project files are used. It should not normally be set by other means.
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_source_pathfile which is part of the GNAT installation tree and is used to store standard libraries such as the GNAT Run Time Library (RTL) source files. Installing a library
Specifying the switch
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
Specifying the switch
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
gnat1 have not been coordinated on this
ALI file will not go to the right place. Therefore, you should
avoid using the
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 further details.
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.