C/C++ Programmer's Guide (G06.27+, H06.03+)

Table Of Contents
Compiling and Linking TNS/E Native C and C++
Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
17-12
Linking a TNS/E Module
3. Generating an object file for the OSS environment:
> CCOMP /IN filec / fileo; SYSTYPE OSS
4. Generating an executable program from a single module:
> CCOMP /IN filec / fileo; RUNNABLE
5. Generating an executable program composed of the modules mod1c, mod2o,
mod3o, and mod4o:
> CCOMP /IN mod1c / fileo; RUNNABLE, LINKFILE "myfile"
In this example, myfile is a text file containing these names of object files (not
source files):
mod2o
mod3o
mod4o
Linking a TNS/E Module
You need to use a linker to collect and combine object files into a program file (an
executable object file or a loadfile) if you did not instruct the compiler to perform the
linking (that is, if you did not use the RUNNABLE pragma when compiling a single-
module program or if you did not use the RUNNABLE and LINKFILE pragmas when
compiling a multiple-module program).
This subsection provides a summary of linking TNS/E native C and C++ programs
using the eld utility, the TNS/E native linker. The eld utility is a linker for PIC
(Position-Independent Code). For more details about PIC and sharing code, see:
Pragma CALL_SHARED on page 13-12
Pragma SHARED on page 13-86
Example of compiling and linking PIC using eld in Examples on page 17-16
For more details about eld, see the eld Manual.
CCPLMAIN File
The CCPLMAIN file, located in $SYSTEM.SYSTEM, contains initialization code for the
TNS/E native C and C++ run-time libraries. This object file must be linked into C and
C++ programs. In many instances, c89, CCOMP and CPPCOMP link, compile, and
automatically include CCPLMAIN.
You need to explicitly link CCPLMAIN when you run the linker to create a loadfile if the
linkfiles were:
Compiled without the RUNNABLE and LINKFILE options when using CCOMP or
CPPCOMP
Compiled with the -c, -Wnolink, or -Wnomain option when using c89