Rational Developer for System z
COBOL for Windows, Version 7.5, Programming Guide


cob2 options

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.

Options that apply to compiling

-c
Compiles programs but does not link them.
-comprc_ok=n
Controls the behavior upon return from the compiler. If the return code is less than or equal to n, cob2 continues to the link step or, in the compile-only case, exits with a zero return code. If the return code generated by the compiler is greater than n, cob2 exits with the same return code returned by the compiler.

The default is -comprc_ok=4.

-dll[:xxx]
Causes cob2 to produce linker files (.LIB and .EXP) to create a DLL named xxx. If xxx is omitted, the name of the first object (.OBJ) or COBOL source (usually .CBL) file specified in the cob2 command is the name of the DLL (and .LIB and .EXP files).
-host
Sets the compiler options for host COBOL data representations and language semantics:

The -host option also affects the format of command-line arguments, as discussed in the related task referenced below.

-Ixxx
Adds path xxx to the directories to be searched for copybooks if a library-name is not specified. (This option is the uppercase letter I, not the lowercase letter l.)

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.

-qxxx
Passes options to the compiler, where xxx is any compiler option or set of compiler options. Do not insert spaces between -q and xxx.

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”

Options that apply to linking

-b“xxx
Passes the string xxx to the linker as parameters. xxx is a list of linker options separated by spaces. The cob2 default parameters are also passed. Do not use spaces immediately after -b.

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
-cmain
Makes a C or PL/I object file that contains a main routine the main entry point in the executable file (.EXE). In C, a main routine is identified by the function name main(). In PL/I, a main routine is identified by the PROC OPTIONS(MAIN) statement.

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.

-imp:xxx.lib
Indicates that xxx.lib is an import library, not a standard library. This value is passed in the generated ILINK command, but not in any generated ILIB commands.
-main:xxx
Makes object file xxx the main program of the executable (.EXE) file. xxx must be the name of an object (.OBJ) file or COBOL source file specified to cob2. xxx cannot appear in a linker response file. For example, the following command causes abc to be the main program.

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.

-s:0xnnnnnnnn
Instructs the linker to allocate nnnnnnnn bytes of stack space to the executable program, where nnnnnnnn is a hexadecimal number. This space might be needed to run programs that have defined very large data items, especially data items in the LOCAL-STORAGE SECTION.
/HEAP:0xnnnnnnnn
Instructs the linker to allocate nnnnnnnn bytes of heap space for static user data, where nnnnnnnn is a hexadecimal number. (The default value is 0x100000, and the maximum is 0xfffffffe.) This space might be needed to run programs that have defined very large data items, particularly data items in the WORKING-STORAGE SECTION.

Options that apply to both compiling and linking

-g
Produces symbolic information used by the debugger. This option is equivalent to compiling with the TEST compiler option and linking with the /DEBUG linker option.
-h
Displays the cob2 help text.
-v
Displays compile and link steps, and executes them.
-#
Displays compile and link steps, but does not execute them.
-?, ?
Displays the cob2 help text.

related tasks
Using command-line arguments

related references
File names and extensions supported by cob2
Compiler environment variables
Runtime environment variables


Terms of use | Feedback

Copyright IBM Corporation 1996, 2008.
This information center is powered by Eclipse technology. (http://www.eclipse.org)