-qmkshrobj

Category

Output control

Pragma equivalent

None.

Purpose

Creates a shared object from generated object files.

Use this option, together with the related options described later in this topic, instead of calling the linker directly (or using the makeC++SharedLib utility, in C++) to create a shared object. The advantages of using this option are the automatic handling of link-time C++ template instantiation (using either the template include directory or the template registry), and compatibility with -qipa link-time optimizations (such as those performed at -O5).

Syntax

Read syntax diagramSkip visual syntax diagram
-qmkshrobj syntax — C

>>- -q--mkshrobj-----------------------------------------------><

Read syntax diagramSkip visual syntax diagram
-qmkshrobj syntax — C++

>>- -q--mkshrobj--+-------------+------------------------------><
                  '-=--priority-'   

Defaults

By default, the output object is linked with the runtime libraries and startup routines to create an executable file.

Parameters

C++ onlypriority
Specifies the priority level for the initialization order of static C++ objects declared in the shared object (relative to static objects declared in other shared objects). The priority may be any number from -214 782 624 (highest priority — initialized first) to 214 783 647 (lowest priority — initialized last). Numbers from -214 783 648 to -214 782 623 are reserved for system use. If no priority is specified a default priority of 0 is used. The priority has no effect if you link shared objects written in C, if you link with the C compiler (xlc), or if the shared object has no static initialization.

Usage

When the -qmkshrobj option is specified, the driver program starts the CreateExportList utility to create an export list from the input list of object files.

The compiler automatically exports all global symbols from the shared object unless you explicitly specify which symbols to export with the -bE:, -bexport: or -bnoexpall options, or if you use the -qnoweakexp option to prevent weak symbols from being exported.

Specifying -qmkshrobj implies -qpic.

You can also use the following related options with -qmkshrobj:

-o shared_file
The name of the file that holds the shared file information. The default is shr.o.
-qexpfile=filename
Saves all exported symbols in filename
-e name
Sets the entry name for the shared executable to name.
-q[no]weakexp
Specifies whether symbols marked as weak (with the #pragma weak directive) are to be included in the export list. If you do not explicitly set this option, the default is -qweakexp (global weak symbols are exported).

For detailed information about using -qmkshrobj to create shared libraries, as well as examples of using -qmkshrobj with priority values, see Constructing a library.

Predefined macros

None.

Examples

To construct the shared library big_lib.so from three smaller object files, enter the following command:
xlc -qmkshrobj -o big_lib.so lib_a.o lib_b.o lib_c.o

Related information