Problem:
How to create an archive that includes a COBOL .o module and statically link it to another COBOL executable.
Resolution:
First you compile your program to .o (the -c cob flag stops the process at .o and doesn't create the executable that the -x option would require):
$ cob -cx hf-test.cbl
Then you create the archive with the ar system tool:
$ ar -r libtst.a test.o
To statically link the code corresponding to the entry "test" inside the libtst.a archive (assuming that the archive is in the current directory, otherwise -L should be use to point to the directory where libtst is):
$ cob -x testmain.cbl -L. -ltss -Itest
The -I cob flag may not be necessary if the program is calling the entry-point directly using LITLINK and the clauses ON OVERFLOW or ON EXCEPTION are not used, but it is always better to be safe by using the -I flag to ensure that the code represented by that symbol is pulled in by the linker.