-shared (-qmkshrobj)

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 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
>>- -shared----------------------------------------------------><

Read syntax diagramSkip visual syntax diagram
>>- -q--mkshrobj-----------------------------------------------><

Defaults

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

Usage

The compiler automatically exports all global symbols from the shared object unless you specify which symbols to export by using the --version-script linker option. IBM extensionSymbols that have the hidden or internal visibility attribute are not exported.IBM extension

Specifying -shared (-qmkshrobj) implies -fPIC (-qpic).

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

-o shared_file
The name of the file that holds the shared file information. The default is a.out.
-e name
Sets the entry name for the shared executable to name.
Note: The -shared (-qmkshrobj) and -static options are incompatible with each other and cannot be specified together.

For detailed information about using -shared (-qmkshrobj) to create shared libraries, 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 -shared -o big_lib.so lib_a.o lib_b.o lib_c.o


Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us