Libraries built as explained above can be used from any program, provided
that the elaboration procedures (named mylibinit in the previous
example) are called before the library services are used. Any number of
libraries can be used simultaneously, as long as the elaboration
procedure of each library is called.

Below is an example of a C program that uses the mylib library.

#include "mylib_interface.h"
int
main (void)
{
/* First, elaborate the library before using it */
mylibinit ();
/* Main program, using the library exported entities */
do_something ();
do_something_else ();
/* Library finalization at the end of the program */
mylibfinal ();
return 0;
}

Note that invoking any library finalization procedure generated by
gnatbind shuts down the Ada run-time environment.
Consequently, the
finalization of all Ada libraries must be performed at the end of the program.
No call to these libraries or to the Ada run-time library should be made
after the finalization phase.

Note also that special care must be taken with multi-tasks
applications. The initialization and finalization routines are not
protected against concurrent access. If such requirement is needed it
must be ensured at the application level using a specific operating
system services like a mutex or a critical-section.