Compilation Tools

This chapter describes how to use OFCOBOL compilation tools.

1. ofcob

Compiles OFCOBOL programs.

  • Usage

    Usage: ofcob <source-file> [options]
  • Options

    You can check compilation options by using the -h option.

    Option Description

    -U

    Specifies the output file as a shared object. (Default)

    -o Output-File

    Specifies an output file name.

    -L

    Specifies the directory that includes the library to link.

    -l

    Specifies the library to link.

    -g

    Leaves debugging information to use ofdebug.

    --version

    Displays the OFCOBOL version.

    --save-temps

    Maintains interim files generated during the compilation process.

    --time-stamp

    Displays the current time when the DISPLAY statement is executed.

    --license

    Displays the license information of OFCOBOL.

    --trace

    Enables READY and RESET TRACE segments in the Procedure Division.

    --noturnc

    Ensures that COMP, COMP-4, and BINARY data maintains the allocated size.

    --force-trace

    Assumes that trace segments are always in use.

    --enable-debug

    Leaves more detailed debugging information.

    --enable-ofasm

    Performs the compilation so that OFASM can be used together.

    --enable-osvs

    Compiles OS/VS COBOL syntax.

    --enable-apost

    Uses apostrophes instead of quotation marks for QUOTE and QUOTES figurative constants.

    --enable-rw

    Compiles syntax related to IBM Report Writer.

    --enable-cbltdli

    Performs the compilation so that the cbltdli function can be called.

    --enable-aertdli

    Performs the compilation so that the aertdli function can be called.

    --enable-aibtdli

    Performs the compilation so that the aibtdli function can be called.

    --enable-host-num-move

    Maintains the sign value of the source in the zoned decimal format.

    --enable-dbcs-literal

    Enables the use of general literals in DBCS.

    --enable-hexa-packed

    Enables the use of hex values in the packed decimal format.

    --enable-caf <funcname>

    Calls the function specified in <funcname> before executing the program.

    --check-file-id

    Checks if the file name is the same as PRGRAM-ID before the compilation.

    --check-index

    Checks index overflow when a program is executed.

    --init-space

    Sets the initial value of variables to spaces.

    --DIR <filename>

    Gets compilation options from the specified file.

    --ptr-redef

    Replaces a COMP variable by a COMP-5 variable if the COMP variable redefines a POINTER variable.

    --enable-asa-byte

    When executing WRITE statement, if AFTER ADVANCING phrases is specified, this optoin adds 1 byte of ASA control character to the beginning of the data set record of the specified file or report file.

    --check-invalid-data

    When executing a MOVE statement, this option generates ABEND if COMP-3 declared source is not packed decimal type.

    --cpm-name <filename>

    The specified file references a CPM table. To reference a CPM table, specify the $OPENFRAME_HOME/lib/libtsys.so library.

    --expanded

    Performs the compilation supporting expanded COBOL syntax.

    --current-date

    Changes the output format of the CURRENT-DATE special register. Only available in OS/VS COBOL.

    --enable-vsc2

    Enables VS COBOL 2.

    --enable-sosi

    Removes Shift-In/Shift-Out Byte from G literal.

    --check-perform-overflow

    Displays an error message if PERFORM Statement’s call stack exceeds 32.

    --file-close-all

    Closes all files automatically when a COBOL program ends.

    --disable-cpy-limit

    Disables the 8-character limit on the target copybook name when using the COPY statement.

    --CURRENCY <Type>

    Enables the use of Japanese yen currency symbol by using back slash (\) as a picture symbol.

    Compile Error

    Finds the error location correctly by creating the .cobi file when a compilation error occurs.

  • Example

    The following compiles the test.cob source file as shared libraries by linking libraries located in /home/ofcob/libpath and /home/ofcob/libpath/newpath. After the compilation, libTest.so and libNewTest.so are created.

    ofcob test.cob -L/home/ofcob/libpath -lTest -L/home/ofcob/libpath/newpath -lNewTest