The following example demonstrates a PL/I CICS program, and COBOL subroutine being compiled and statically linked together.
Source Program (T23652P.pli):
T23652P: PROC() OPTIONS(MAIN);
DCL 1 COBPARM,
2 COBCODE CHAR(3),
2 COBNAME CHAR(30),
2 COBSTAT FIXED BIN(15);
DCL T23652C ENTRY OPTIONS(COBOL);
EXEC CICS WRITE OPERATOR TEXT('T23652P starts');
COBCODE = "AAA";
EXEC CICS WRITE OPERATOR TEXT('T23652P - T23652C');
CALL T23652C (COBPARM);
EXEC CICS WRITE OPERATOR TEXT(COBNAME);
EXEC CICS WRITE OPERATOR TEXT('T23652P end');
END T23652P;
Source Program (T23652C.cbl ):
working-storage section.
linkage section.
01 lk-params.
05 lk-code pic X(3).
05 lk-name pic X(30).
05 lk-stat pic S9(4) COMP.
procedure division using lk-params.
evaluate lk-code
when "AAA" move "T23652C is called with AAA" to lk-name
when "BBB" move "T23652C is called with BBB" to lk-name
when "CCC" move "T23652C is called with CCC" to lk-name
when other move spaces to lk-name
end-evaluate.
goback.
Commands:
export COBMODE=32
mfplx -cics -c T23652P.pli -o T23652P.o
cob -xc T23652C.cbl
cob -z T23652P.o T23652C.o $COBDIR/lib/32/systemcics.o -L$COBDIR/lib -lmfpliz -lplidump -lmfpdfpz
ldpli -verbose foo.o -systemmvs
Where foo is the name of the object file.
The system returns information including the ldpli libraries. For example:
ld -o "a.out"
-m elf_i386 -Bdynamic -dynamic-linker /lib/ld-linux.so.2 -shared --unresolved-symbols=ignore-in-shared-libs -lc --eh-frame-hdr
"foo.o"
/home1/hub/axle/axle76/pkg/lib/32/dllmain.o
-L/home1/hub/axle/axle76/pkg/lib -lmfpliz -lplidump -llmgr
-L/usr/lib -lm -lrt
In this case, the libraries you need to match for the cob linker are:
This example depicts 32-bit mode. When run in 64-bit mode, names of the libraries might be different in 64-bit mode. Also in 64-bit mode, dllmain_cob.o replaces dllmain.o.