The following examples illustrate the use of cob2 for linking.
To link two files together, compile them without the -c option. For example, to compile and link alpha.cbl and beta.cbl and generate alpha.exe, enter:
cob2 alpha.cbl beta.cbl
The command above creates alpha.obj and beta.obj, then links alpha.obj, beta.obj, and the COBOL libraries. If the link step is successful, it produces an executable program named alpha.exe.
The following command compiles beta.cbl:
cob2 alpha.obj beta.cbl mylib.lib gamma.exe
It also passes this string to the linker:
alpha.obj beta.obj mylib.lib /out:gamma.exe
If linking is successful, the executable gamma.exe is produced.
The following command produces alpha.dll, assuming a valid alpha.def file:
cob2 -dll alpha.cbl alpha.def
related tasks
Linking from the command line