A Stand-alone Library is a library that contains the necessary code to elaborate the Ada units that are included in the library. A Stand-alone Library is suitable to be used in an executable when the main is not in Ada. However, Stand-alone Libraries may also be used with an Ada main subprogram.
A Stand-alone Library Project is a Library Project where the library is a Stand-alone Library.
To be a Stand-alone Library Project, in addition to the two attributes
that make a project a Library Project (
Library_Dir, see Library Projects), the attribute
Library_Interface must be defined.
for Library_Dir use "lib_dir"; for Library_Name use "dummy"; for Library_Interface use ("int1", "int1.child");
Library_Interface has a nonempty string list value,
each string in the list designating a unit contained in an immediate source
of the project file.
When a Stand-alone Library is built, first the binder is invoked to build a package whose name depends on the library name (b~dummy.ads/b in the example above). This binder-generated package includes initialization and finalization procedures whose names depend on the library name (dummyinit and dummyfinal in the example above). The object corresponding to this package is included in the library.
A dynamic or relocatable Stand-alone Library is automatically initialized
if automatic initialization of Stand-alone Libraries is supported on the
platform and if attribute
Library_Auto_Init is not specified or
is specified with the value "true". A static Stand-alone Library is never
Single string attribute
Library_Auto_Init may be specified with only
two possible values: "false" or "true" (case-insensitive). Specifying
"false" for attribute
Library_Auto_Init will prevent automatic
initialization of dynamic or relocatable libraries.
When a non-automatically initialized Stand-alone Library is used in an executable, its initialization procedure must be called before any service of the library is used. When the main subprogram is in Ada, it may mean that the initialization procedure has to be called during elaboration of another package.
For a Stand-Alone Library, only the ALI files of the Interface Units
(those that are listed in attribute
Library_Interface) are copied to
the Library Directory. As a consequence, only the Interface Units may be
imported from Ada units outside of the library. If other units are imported,
the binding phase will fail.
When a Stand-Alone Library is bound, the switches that are specified in
Default_Switches ("Ada") in package
used in the call to gnatbind.
The string list attribute
Library_Options may be used to specified
additional switches to the call to gcc to link the library.
Library_Src_Dir, may be specified for a
Library_Src_Dir is a simple attribute that has a
single string value. Its value must be the path (absolute or relative to the
project directory) of an existing directory. This directory cannot be the
object directory or one of the source directories, but it can be the same as
the library directory. The sources of the Interface
Units of the library, necessary to an Ada client of the library, will be
copied to the designated directory, called Interface Copy directory.
These sources includes the specs of the Interface Units, but they may also
include bodies and subunits, when pragmas
are used, or when there is a generic units in the spec. Before the sources
are copied to the Interface Copy directory, an attempt is made to delete all
files in the Interface Copy directory.