Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Systems: HP aC++/HP C Programmer's Guide > Chapter 2 Command-Line Options

Libraries

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

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

-b

-b

The -b option 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”.

-dynamic

-dynamic

The -dynamic option produces dynamically bound executables. See “-minshared” for partially statically bound executables.

The default is -dynamic.

-exec

-exec

The -exec option 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 parameter forms part of the name of a library the linker searches for when looking for routines called by your program.

The -lname option 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 -a linker option or the -minshared compiler option.

NOTE: Because a library is searched when its name is encountered, placement of a -l is 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 if it is installed on your system.

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.

-L directory

-L directory

The directory parameter is the HP-UX directory where you want the linker to search for libraries your program uses before searching the default directories.

The -L directory option causes the linker to search for libraries in directory in addition to using the default search path.

See -lname option for default search path.

The -L option must precede any -lname option entry on the command line; otherwise -L is ignored. This option is passed directly to the linker.

Example:

The following example compiles and links prog.C and directs the linker to search the directories and /project/libs for any libraries that prog.C uses (in this case, mylib1 and mylib2).

aCC -L/project/libs prog.C -lmylib1 -lmylib2

-minshared

-minshared

The -minshared option indicates that the result of the current compilation is going into an executable file that will make minimal use of shared libraries. This option is equivalent to -exec -Bprotected.

+nostl

+nostl

By eliminating references to the standard header files and libraries bundled with HP aC++, the +nostl option allows experienced users full control over the header files and libraries used in compilation and linking of their applications, without potential complications that arise in mixing different libraries.

NOTE: Complete understanding of the linking process and the behavior of the actual (third party) libraries linked with the application is essential to avoid link or run-time failures.

For more information on shared libraries, see “Creating and Using Libraries”.

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© Hewlett-Packard Development Company, L.P.