Constructing a Library

Libraries with Non-Shared Files
Nonshared files are files that are linked into the C++ executable program. You can use the ar command to construct a library containing non-shared files that have objects with specified priority levels.

To construct this archive file:

For example, to produce an archive file animal_order.a using the two files from the previous example, farm.o and zoo.o, enter:

ar rv animal_order.a farm.o zoo.o

If your archive file contains files that were compiled without specifying the -qpriority=N option, and they contain no #pragma priority(N) directives, they are treated as having been compiled with -qpriority=0. Objects in any files compiled with a priority number less than 0 are initialized before this file, and any objects from files compiled with a priority number greater than 0 are initialized after it.

All files that have the same priority level are initialized in random order.

The objects in files that contain #pragma priority(N) directives are initialized in the order specified by the directives within the files.

You can place any number of files with specified priorities in the archive file.

You can use this archive file, along with other object and archive files, as input to the makeC++SharedLib program to make a library of shared and nonshared files.

 

Libraries with Shared Files
Shared files are files that are used by more than one program.

To ensure that the objects in shared files are properly initialized, you must construct libraries containing these shared files. To construct these libraries, you use the makeC++SharedLib program found in /usr/ibmcxx/bin.

You can then combine several of these libraries using the AIX ar command to produce an archive file made up of several shared and nonshared libraries so that initialization of the objects takes place in the order you have specified.



Overview of Shared Library Initialization
Specifying Priority Levels for Library Objects
Example of Object Initialization in a Group of Files


ar Command
makeC++SharedLib Command
priority Compiler Option