C/C++ Programmer's Guide (G06.25+)

Mixed-Language Programming for TNS/R and
TNS/E Native Programs
HP C/C++ Programmer’s Guide for NonStop Systems429301-008
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 nld or ld on a G-series system or eld on an H-series
system:
ld /usr/lib/ccppmain.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. To 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 nld or ld on a G-series system or eld on an H-series
system:
ld $system.system.ccppmain testco testcobo -o testexe -obey
$system.system.libcobey -l zcobsrl