Kenwood HP 9000 Personal Computer User Manual


 
Chapter 6 211
Shared Library Management Routines
Initializers for Shared Libraries
Init/Fini style: see “Init/Fini Style Initializers” and the topics
described in this section:
“Init and Fini Usage Example”
“Ordering Within an Executable or Shared Library”
“Ordering Among Executables and Shared Libraries”
Init and Fini Usage Example
This example consists of three shared libraries lib1.sl, lib2.sl and
lib3.sl. The lib1.sl depends on lib3.sl. The main program (a.out)
depends on lib1.sl and lib2.sl. Each shared library has an init
style initializer and a fini style terminator. The lib1.sl and lib2.sl
uses linker options (+init and +fini) to specify the initializers and
terminators and lib3.sl uses compiler pragmas.
C source for lib1.sl (file lib1.c):
lib1()
{
printf(“lib1\n”);
}
void
lib1_init()
{
printf(“lib1_init\n”);
}
void
lib1_fini()
{
printf(“lib1_fini\n”);
}
C source for lib2.sl (file lib2.c):
lib2()
{
printf(“lib2\n”);
}
void
lib2_init()
{
printf(“lib2_init\n”);
}
void
lib2_fini()
{
printf(“lib2_fini\n”);
}