HP C A.06.05 Reference Manual

Compiling and Running HP C Programs
Compiling HP C Programs
Chapter 9208
Compiling HP C Programs
When you compile a program, it passes through one or more of the following steps depending
upon which command line options you use:
Preprocessor: This phase examines all lines beginning with a # and performs the
corresponding actions and macro replacements.
Compilation Process: This phase takes the output of the preprocessor and generates
object code.
Optimization: This optional phase optimizes the generated object code.
Linking: In this phase, the linker is invoked to produce an executable program. External
references in shared and archived libraries are resolved as required. The startup routines
are copied in, and the C library in /usr/lib/hpux##/lib.so (## is 32 or 64) is referenced.
(By default, shared libraries take precedence over archived libraries if both versions are
available. However, if you use the LPATH environment variable, you should make sure that
all shared libraries come before any archive library directories. See the HP-UX Linker
and Libraries Online User Guide for information on LPATH or on creating and linking with
shared libraries.) Object modules are combined into an executable program file.
The cc(1) Command
Use the cc(1) command to compile HP C programs. It has the following format:
cc [
options
]
files
where:
options
is one or more compiler options and their arguments, if any. Options can be
grouped together under one minus sign.
files
is one or more file names, separated by blanks. Each file is either a source or
an object file.
Specifying Files to the cc Command
Files with names ending in .c are assumed to be HP C source files. Each HP C source file is
compiled, producing an object file with the same name as the source file except that the .c
extension is changed to a .o extension. However, if you compile and link a single source file
into an HP C program in one step, the .o file is automatically deleted.