To specify a cob2 option, precede it by a hyphen (-). Do not use a slash (/) for options unless you want to pass those options to the linker using cob2. Any options that you specify in the cob2 command that are not listed below are passed to the linker.
The default is -comprc_ok=4.
The -host option also affects the format of command-line arguments, as discussed in the related task referenced below.
Only a single path is allowed for each -I option. To add multiple paths, use multiple -I options. Do not insert spaces between -I and xxx.
If you use the COPY statement, you must ensure that the LIB compiler option is in effect.
If a parenthesis is part of the compiler option or suboption, or if a series of options is specified, include them in quotation marks.
To specify multiple options, delimit each option by a blank or comma. For example, the following two option strings are equivalent:
-qoptiona,optionb
-q“optiona optionb”
Alternatively, you can specify linker options directly as individual cob2 options. For example, to pass the /DE option to the linker, use this command:
cob2 /DE myprog.cbl
If you link a C or PL/I object file that contains a main routine with one or more COBOL object files, you must use -cmain to designate the C or PL/I routine as the main entry point in the executable file. A COBOL program cannot be the main entry point in an executable file that contains a C or PL/I main program. Unpredictable behavior occurs if this is attempted, and no diagnostics are issued.
For example, the following two commands are equivalent:
cob2 -cmain myCmain.obj myCOBOL.obj
cob2 -cmain myCOBOL.obj myCmain.obj -main:myCmain
Either command generates the executable file myCmain.exe. The main entry is the C main() function contained in the myCmain.obj object file.
This option presents runtime command-line arguments in host data format, that is, EBCDIC for character data and big-endian for binary data.
cob2 -main:abc a1.cbl d:\cats\abc.obj b2.cbl
If -main is not specified, the first object or source file specified becomes, in the absence of a linker response file, the COBOL main program.
If the syntax of -main:xxx is invalid, or xxx is not the file-name of an object or source file processed by cob2, cob2 terminates.
related tasks
Using command-line arguments
related references
File names and extensions supported by cob2
Compiler environment variables
Runtime environment variables