aura library [-no-pie] [-debug] [-static/-static-rt] [-assertions] [-optimize-(1/2/3/size/debug)] library_name.a/lob/so/dylib/dll
library command generates a standard library object/archive that is intended to be used by a non-Ada program.
library command implicitly invokes compile before generating either a dynamic or static library image.
The generated library will always contain all of the project’s root library units, and will also contain special elaboration and finalization C convention exported routines,
For supported platforms (most modern UNIX environments), dynamic libraries will be linked with self-initialization and finalization pointing to the
adafini(), so that use of such libraries will not need explicit calls to
adainit() more than once is supported, and so it is still recommended that these routines are explicitly called, even when using a shared library.
Users of a static AURA-generated library MUST invoke
adainit() before invoking any other subprogram exported from the library.
The type of library (static or dynamic) is determined by the extension of the library_name parameter. The extension is platform-specific.
- Static Libraries
For UNIX environments, static libraries are generated if the extension is ‘.a’. For Windows, the extension would be ‘.lib’.
Static libraries always imply the -static option.
A self-contained copy of the Ada runtime is directly included in the library.
Depending on the platform, an additional file named library_name.linkopt is generated by AURA. This file contains a computed set of linker options that must be included when using (linking in) the static library.
Since all libraries generated by AURA will include initialization and finalization routines (
adafini()), it will typically be impossible to use more than one AURA-generated library in a single program.
The ability to specify the names of the initialization and finalization subprograms may be added at a later time.
- Dynamic Libraries
For most UNIX environments, dynamic libraries are generated if the extension is ‘.so’. For MacOS (Darwin), the extension is ‘.dylib’. For Windows, the extension is ‘.dll’.
Note that, unless -static/-static-rt is given, the resulting dynmaic library will itself have dynamic library linkages to (at a minimum) the Ada runtime.
Using the library generation feature is the best way to integrate Ada codebases into less Ada-friendly environments. A great example is a mobile app. With the appropriate cross-compiler (such as gcc), one can generate an all-Ada library that contains the bulk of the program, and simply invoke it from the application’s main subroutine. As long as it is possible to use standard library objects/archive, and to call C functions, it will be possible to use Ada.