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 Systems429301-008
16-12
Linking a Module
The compiler returns one of the following completion codes:
Examples
1. Directing the compiler to translate the source file ABSC (which contains an entire
C++ program), sending the compiler listing to the device $S.#ABSL, storing the
object file under the name ABSO, and using the default VERSION3 library:
> NMCPLUS /IN absc, OUT $s.#absl/ abso;
2. Disabling the run-time diagnostics that the assert function can issue by defining
NDEBUG as a preprocessor symbol:
> NMC /IN appc, OUT $s.#appl/ appo; define NDEBUG
3. Generating a TNS/R native object file for the OSS environment:
> NMC /IN filec / fileo; SYSTYPE OSS
4. Generating an executable TNS/R native program from a single module:
> NMC /IN filec / fileo; RUNNABLE
5. Generating an executable TNS/R native program composed of the modules
mod1c, mod2o, mod3o, and mod4o:
> NMC /IN mod1c / fileo; RUNNABLE, LINKFILE "myfile"
In this example, myfile is a text file containing the following names of object files
(not source files):
mod2o
mod3o
mod4o
Linking a 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 C and C++ programs using the nld
utility, the TNS/R native linker for conventional applications. For complete details about
using nld, see the nld Manual.
0 The compilation completed successfully.
1 The compilation completed with warnings (but no errors).
2 The compilation completed with errors.
3 The compiler terminated abnormally as the result of an internal error.