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

Table Of Contents
Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-010
8-29
Interfacing to Native COBOL
Compiling and Linking the COBOL and C Programs
To compile the programs in the OSS environment:
1. Compile the COBOL function named testcob.cob using the TNS/R native
COBOL compiler:
nmcobol -c testcob.cob
or compile the function using the TNS/E native COBOL compiler:
ecobol -c testcob.cob
2. Compile the C program named testc.c using c89:
c89 -c testc.c
The resulting object file is named testc.o.
3. Link the object files using TNS/R native linker on a NonStop S-series system or
eld on a NonStop NS-series system:
nld /usr/lib/crtlmain.o testc.o testcob.o -o test.exe -obey
/G/system/system/libcobey -l zcobsrl
or
eld /usr/lib/ccplmain.o testc.o testcob.o -o test.exe
-l zcobdll
4. Run the program:
./test.exe
To compile the programs in the Guardian environment:
1. Compile the COBOL function named testcob using the TNS/R native COBOL
compiler:
nmcobol /in testcob / testcobo
or compile the function using the TNS/E native COBOL compiler:
ecobol /in testcob / testcobo
2. Compile the C program named testc using the TNS/R native C compiler:
nmc / in testc/ testco
or compile the function using the TNS/E native C compiler:
ccomp / in testc/ testco
3. Link the object files using TNS/R native linker on a NonStop S-series system or
eld on a NonStop NS-series system:
nld $system.system.crtlmain testco testcobo -o testexe -obey
$system.system.libcobey -l zcobsrl