C/C++ Programmer's Guide (G06.25+)
Compiling and Linking TNS/R Native C and C++ 
Programs
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
16-13
Linking a Module
The ld utility is the linker for PIC (Position-Independent Code). For more information 
about PIC and sharing code, see:
•
Pragma CALL_SHARED on page 13-12
•
Pragma NON_SHARED on page 13-68
•
Pragma SHARED on page 13-85
•
Example of compiling and linking PIC using ld in Examples on page 16-17
For more information about ld, see the ld Manual.
CRTLMAIN File
The CRTLMAIN file, located in $SYSTEM.SYSTEM, contains initialization code for the 
TNS/R native C and C++ run-time libraries. This object file must be linked into C and 
C++ programs. In many instances, c89, NMC and NMCPLUS link, compile, and 
automatically include CRTLMAIN. 
You need to explicitly link CRTLMAIN when you run the linker to create a loadfile if the 
linkfiles were: 
•
Compiled without the RUNNABLE and LINKFILE options when using NMC or 
NMCPLUS
•
Compiled with the -c, -Wnolink, or -Wnomain option when using c89
The PIC (Position-Independent Code) variant of CRTLMAIN is named CCPPMAIN. On 
OSS, the PIC variant of crtlmain.o is ccppmain.o.
A similar initialization file for doing fault-tolerant programming, named CRTLNS, also 
might need to be linked. The PIC variant is CRTLNS2. On OSS, the PIC variant of 
crtlns.o is crtlns2.o.
Shared Run-Time Libraries (SRLs)
An SRL contains code present in virtual memory at run time, to be shared by other 
processes, rather than code that is linked into object files. An SRL can also contain 
global data, and each process using the SRL automatically gets its own run-time copy 
of the data, called instance data. A process can use several SRLs.
Some of the code configured in the system library for TNS processes is packaged in 
SRLs for TNS/R native processes. For example, the TNS/R C run-time library, the 
TCP/IP sockets library, the Tools.h++ class library, and much of the OSS API are 
packaged as SRLs for TNS/R native processes. HP supplies public SRLs; you cannot 
create your own public SRLs.
Each processor loads its public SRLs at startup from the active SYSnn subvolume. 
The SYSnn subvolume, located on $SYSTEM, contains a version of the operating 
Note. nld supports native SRLs. It does not support the TNS shared run-time library available 
to TNS and accelerated programs in the OSS environment. For details about the TNS SRL, 
refer to the Binder Manual.










