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

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 system image for a particular
node. A node can have more than one SYSnn subvolume, but only one active (running) SYSnn
subvolume.
When you use nld to build an executable program, nld fixes up references to the SRLs that you
have specified. You can also use nld to repeat the fix-up process on an existing program to use
a new version of an SRL or let the operating system update the references when you execute the
program.
To create an executable C or C++ program using nld:
1. Specify $SYSTEM.SYSTEM.CRTLMAIN (or CCPPMAIN for PIC code) to link to the TNS/R
native C and C++ run-time library initialization object code file for non-PIC code.
2. Specify the object code files that you compiled.
3. Specify the shared run-time libraries (SRLs) used by your program.
The LIBCOBEY file is a linker command file that identifies the standard set of C SRLs. Specifying
-OBEY $SYSTEM.SYSTEM.LIBCOBEY is sufficient to link the SRLs used by most C programs.
C++ programs require you to specify additional SRLs. For complete details, see Determining
Which SRLs are Required (page 295).
4. If your program uses the active backup programming functions, such as
__ns_start_backup(), specify the active backup programming support object code file
$SYSTEM.SYSTEM.CRTLNS for non-PIC code or $SYSTEM.SYSTEM.CRTLNS2 for PIC code.
Command examples are shown in Examples (page 297).
SRLs and Dynamic-Link Libraries (DLLs)
The NonStop system libraries at G06.20 are compatible with the use of dynamic-link libraries
(DLLs). When a NonStop server is migrated to G06.20, the system shared run-time libraries (SRLs)
are automatically migrated to become hybrid SRLs, which are public libraries in PIC
(Position-Independent Code) format.
You can use the ld utility to create a linkable object file or linkfile. You can also use ld to create
an executable (known as a loadable object file or a loadfile) in PIC format that can function as a
shared library or dynamic-link library (DLL).
Determining Which SRLs are Required
The SRLs that are required by a program depend on whether the program:
Runs in the NonStop environment
Uses the C run-time library
Uses the C++ run-time library
Uses the Tools.h++ library (and whether Version 6.1 or Version 7)
Uses the Standard C++ Library
Uses the TCP/IP sockets library
Table 45: SRLs Available When Using VERSION1, VERSION2, and VERSION3 is a conceptual
stack of the SRLs that make up the context of VERSION1, VERSION2, and VERSION3. In this table,
CRTL represents the SRL named ZCRTLSRL (the C run-time library). RWSLSRL is given as RWSL
(the VERSION2 Standard C++ Library, which is a port of the Rogue Wave standard library).
Working in the Guardian Environment 295