Sun Studio 12 Update 1: C++ User's Guide

A.2.34 –h[ ]name

Assigns the name name to the generated dynamic shared library.

This is a linker option, passed to ld. In general, the name after -h should be exactly the same as the one after –o. A space between the –h and name is optional.

The compile-time loader assigns the specified name to the shared dynamic library you are creating. It records the name in the library file as the intrinsic name of the library. If there is no –hname option, then no intrinsic name is recorded in the library file.

Every executable file has a list of shared library files that are needed. When the runtime linker links the library into an executable file, the linker copies the intrinsic name from the library into that list of needed shared library files. If there is no intrinsic name of a shared library, then the linker copies the path of the shared library file instead.

When a shared library is built without the-h option, the runtime loader looks only for the file name of the library. You can replace the library with a different library with the same file name. If the shared library has an intrinsic name, the loader checks the intrinsic name when loading the file. If the intrinsic name does not match, the loader will not use the replacement file.

A.2.34.1 Examples


example% CC -G -o libx.so.1 -h libx.so.1 a.o b.o c.o