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-14
Linking a Module
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 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 on
page 16-14.
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.
Command examples are shown in Examples on page 16-17.
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 Guardian or OSS 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