HP C/iX Reference Manual (31506-90011)

122 Chapter8
Compiling and Running HP C/iX Programs
Linking the C Library
Linking the C Library
This section describes the procedure necessary to link C library functions into your
program using the MPE/iX LINK command. For many applications, linking the
LIBCINIT.LIB.SYS file in the RL list, as done by the CCXLLK and CCXLGO commands, is
sufficient. Applications that use mathematical or random number functions, or programs
compiled using ANSI mode, will nee to link with additional libraries.
C Library Organization
The C library consists of several files that may be separated into two functional areas: the
standard library and the mathematical library.
The standard library consists of the input/output functions, the general utility functions
that perform operations such as string and memory manipulation, and the program
startup functions. All C programs must link in the standard library because it contains the
startup routines necessary for program execution. Failure to link in this library will result
in a linker or loader error. The standard library is available in the system executable
library (XL.PUB.SYS) and also as a relocatable library (RL).
The math library consists of additional mathematical functions, such as the trigonometric
and logarithmic functions, that perform floating point operations. The math library is only
available in RL form.
For further information on the organization of the HP C/iX Library, refer to the HP C/iX
Library Reference Manual.
Linking the Library Files
To use the executable standard library, add the LIBCINIT.LIB.SYS file to the RL list when
linking your program. To use the relocatable standard library, add the LIBC.LIB.SYS file
to the RL list when linking. Note that you may choose either the executable (XL) or
relocatable (RL) library form, but not both.
Additionally, if the program is compiled using ANSI mode (the -Aa option), the relocatable
library LIBCANSI.LIB.SYS must also be added to the RL list regardless of whether
LIBCINIT.LIB.SYS or LIBC.LIB.SYS is used. This is to ensure that certain file behaviors
conform to ANSI specifications. For a detailed description of LIBCANSI.LIB.SYS, see the
HP C/iX Library Reference Manual. For a detailed discussion of the LINK command, see
the MPE/iX Commands Reference Manual.
To use the math library, add the LIBM.LIB.SYS file to the RL list when linking your
program. The LIBM.LIB.SYS file must precede the LIBC.LIB.SYS file in the RL list if the
RL form of the standard library is used. The ordering of the files is significant because of
the interdependencies of the libraries. The ordering is not significant if the XL form of the
standard library is linked.
In addition to LIBM.LIB.SYS, there is also LIBMANSI.LIB.SYS, the ANSI conforming
version of the math library. You must decide which version of the math library to use and
link with the appropriate RL.