cob2, cob2_j, and cob2_r options

The options listed below apply to all of the invocation commands: cob2, cob2_j, and cob2_r.

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, the command 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, the command exits with the same return code returned by the compiler.

The default is -comprc_ok=4.

-host
Sets these compiler options for host COBOL data representation and language semantics:
  • CHAR(EBCDIC)
  • COLLSEQ(EBCDIC)
  • NCOLLSEQ(BIN)
  • FLOAT(S390)

The -host option changes the format of COBOL program command-line arguments from an array of pointers to an EBCDIC character string that has a halfword prefix that contains the string length. For additional information, see the related task below about using command-line arguments.

If you use the -host option and want a main routine in a C or PL/I object file to be the main entry point of your application, you must use the -cmain linker option as described below.

-Ixxx
Adds path xxx to the directories to be searched for copybooks if neither a library-name nor SYSLIB is 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"

If you plan to use a shell script to automate your cob2 tasks, a special syntax is provided for the -qxxx option. For details, see the related task about compiling using shell scripts.

Options that apply to linking

-cmain
(Has an effect only if you also specify -host.) Makes a C or PL/I object file that contains a main routine the main entry point in the executable file. 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. A COBOL program cannot be the main entry point in an executable file that contains a C or PL/I main routine. Unpredictable behavior occurs if this is attempted, and no diagnostics are issued.

-main:xxx
Makes xxx the first file in the list of files passed to the linker. The purpose of this option is to make the specified file the main program in the executable file. xxx must uniquely identify the object file or the archive library, and the suffix must be either .o or .a, respectively.

If -main is not specified, the first object, archive library, or source file specified in the command is the first file in the list of files passed to the linker.

If the syntax of -main:xxx is invalid, or if xxx is not the name of an object or source file processed by the command, the command terminates.

-o xxx
Names the executable module xxx, where xxx is any name. If the -o option is not used, the name of the executable module defaults to a.out.
-p
Instructs the linker to set up the object file produced by the compiler for AIX profiling (command used to evaluate program performance) with minimum profiling information.
-pg
Instructs the linker to set up the object file produced by the compiler for AIX graph profiling (command used to evaluate program performance) with maximum profiling information.

Options that apply to both compiling and linking

-Fxxx
Uses xxx as a configuration file or a stanza rather than the defaults specified in the /etc/cob2.cfg configuration file. xxx has one of the following forms:
  • configuration_file:stanza
  • configuration_file
  • :stanza
-g
Produces symbolic information used by the debugger.
-q32
Specifies that a 32-bit object program is to be generated. Sets the ADDR(32) compiler option. Sets the -b32 linker option, which instructs the linker to create a 32-bit executable module.
-q64
Specifies that a 64-bit object program is to be generated. Sets the ADDR(64) compiler option. Sets the -b64 linker option, which instructs the linker to create a 64-bit executable module.
-v
Displays compile and link steps, and executes them.
-#
Displays compile and link steps, but does not execute them.
-?, ?
Displays help for the cob2, cob2_j, or cob2_r command.

related references  
Compiler environment variables  
ADDR