HP C/aC++ for PA-RISC Software manual Library Options, Dynamic, Exec, Lname

Models: C/aC++ for PA-RISC Software

1 230
Download 230 pages 50.97 Kb
Page 49
Image 49

Library Options

Library options allow you to create, use, and manipulate libraries.

-b

-b

The -boption creates a shared library rather than an executable file.

Example:

The following command links utils.o and creates the shared library utils.so.

aCC -b utils.o -o utils.so

For more information on shared libraries, see “Creating and Using Libraries” (page 175).

-dynamic

-dynamic

The -dynamicoption produces dynamically bound executables. See “-minshared” (page 50) for partially statically bound executables.

The default is -dynamic.

-exec

-exec

The -execoption indicates that any object file created will be used to create an executable file. Constants with a protected or hidden export class are placed in the read-only data section. This option also implies -Bprotected_def. It makes all defined functions and data (even tentatively defined data) protected by default (unless otherwise specified by another binding option or pragma).

-lname

-lname

The name value forms part of the name of a library the linker searches for when looking for routines called by your program.

The -lnameoption causes the linker to search one of the following default libraries, if they exist, in an attempt to resolve unresolved external references:

/usr/lib/lib/hpux32/name.so

/usr/lib/lib/hpux32/name.a

/opt/langtools/lib/hpux32lib/name.so

/opt/langtools/lib/hpux64lib/name.a

Whether it searches the shared library (.so) or the archive library (.a) depends on the value of the -alinker option or the -minsharedcompiler option.

NOTE: Because a library is searched when its name is encountered, placement of a -lis significant. If a file contains an unresolved external reference, the library containing the definition must be placed after the file on the command line. For details refer to the description of ld in the HP-UX Reference Manual or the ld(1) manpage for more information.

Example:

aCC file.o -lnumeric

This command directs the linker to link file.o and (by default) search the library /usr/lib/ hpux32/libnumeric.so.

Library Options 49

Page 49
Image 49
HP C/aC++ for PA-RISC Software manual Library Options, Dynamic, Exec, Lname