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

Table Of Contents
Compiling and Linking TNS/R Native C and C++
Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
16-10
Compiling a Module
A nonexecutable object file, if the compiler encountered no errors during the
compilation.
After compiling all the modules that compose your program, you collect and combine
them into a program file (an executable object file) by using the nld utility for
conventional code or the ld utility for PIC (Position-Independent Code).
If your program comprises a single module, you can use the RUNNABLE pragma to
direct the compiler to produce a program file instead of a nonexecutable object file.
If your program comprises more than one module, you can use the RUNNABLE and
LINKFILE pragmas to direct the compiler to produce a linked program file instead of a
nonexecutable object file. For more details, see pragma LINKFILE on page 13-57.
To use the RUNNABLE pragma, one of the modules must contain the main function of
the program.
When you specify the RUNNABLE pragma, the native C and C++ compilers specify the
$SYSTEM.SYSTEM.LIBCOBEY command file to the linker. The LIBCOBEY file directs
TNS/R native linker to link to a set of standard shared run-time libraries (SRLs). For
most C and C++ programs, this set of SRLs is sufficient to create an executable
program. If your program requires SRLs not specified in LIBCOBEY (such as the
Tools.h++ SRL) you can direct TNS/R native linker to search additional SRLs using the
LINKFILE pragma.
The NMC command invokes the TNS/R native C compiler. The NMCPLUS command
invokes the TNS/R native C++ compiler. The syntax for these commands is shown in
this diagram.
[ RUN ] NMC
is the TACL command to start the TNS/R native C compiler process. The RUN
command keyword is optional.
[ RUN ] NMCPLUS
is the TACL command to start the TNS/R native C++ compiler process. The RUN
command keyword is optional.
[ RUN ] { NMC | NMCPLUS } / IN source [ , OUT listing ]
[ , run-options ] / [ object ]
[ ; compile-option [ , compile-option ]... ]
compile-option:
{ pragma }
{ define identifier [ constant ] }
{ undefine identifier }