Skip to content

Compiler Environment Variables

The following environment variables are used by cobc, the COBOL-IT compiler, at compilation time.

  • COB_AR <program>

    Default is ar on Unix/Linux-based systems and lib.exe on Windows-based systems. Designates archive program to be used by cobc.

  • COB_ARFLAGS <ar flags>

    Designates archive flags used by cobc.

  • COB_CC <program>

    Designates C compiler used by cobc.

  • COB_CFLAGS <cc flags>

    Default is -I$COBOLITDIR/include on Unix/Linux-based sytems and -I%COBOLITDIR%\include on Windows.

    Designates C compiler flags used by cobc.

    If defined, replaces the default settings used by cobc as the C compiler flags.

  • COB_CONFIG_DIR<directory>

    Default is $COBOLITDIR/share/COBOL-it/config on Unix/Linux-based systems, and %COBOLITDIR%/config on Windows-based systems.

    Designates the location of the compiler configuration file.

  • COB_CONSOLE_CP=<codepage-id>

    The COB_CONSOLE_CP=<codepage-id> runtime environment variable, when defined, causes the DISPLAY UPON CONSOLE/DISPLAY UPON SYSOUT phrases to convert the codepage defined using the -fcodepage compiler flag to <codepage-id>.

    As an example (on a Linux X Console):

       >cobc -x myprog.cob -fcodepage latin1 
       export COB_CONSOLE_CP=UTF-8 
       ./myprog
    

    Will correctly display literals encoded in latin1 on the console.

  • COB_COPY_DIR<directory>

    Default is $COBOLITDIR/share/COBOL-it/copy on Unix/Linux-based systems, and %COBOLITDIR%\copy on Windows-based systems.

    Designates the location of COPY files.

  • COB_EXTRA_FLAGS

    Designates C compiler flags added when -O2 option is used or when -O is used without prior -Os.

  • COB_LDADD <ld flags>

    Sets an additional link command to be used by cobc.

    Example:

    COB_LDADD= -L/my/ownlibpath/ -lmylibs; export COB_LDADD

  • COB_LDFLAGS <ld flags>

    Designates linker flags used by cobc. If defined, cobc does not compute the needed linker flags.

  • COB_LIBS <libs>

    Default is -L/opt/COBOL-it/lib -lcob -lgmp -ldb on Unix/Linux-based systems, and /LIBPATH:C:\COBOL\COBOLIT\lib\ libcobit_dll.lib on Windows-based systems

    Designates C compiler library flags used by cobc.

  • COB_OPTIMIZE_FLAG<cc flags>

    Default is: -O2

    Designates C compiler flags added when -O option is used.

    Warning

    On some platforms, using an optimization level greater than 2 can produce an unstable program.

  • COB_OPTSIZE_FLAG=[optimization flag]

    Default is: -O2

    Designates flag to be used in the C compilation phase for the purpose of optimization.

    Usage: To cause the -Os flag to be used by the C compiler

    export COB_OPTSIZE_FLAG=-Os

  • COB_STDUNIX <1/0>

    Default is: 0

    When set to 1, on Windows-based systems, indicates that end-of-line is marked by LF, not CR/LF as is the default on Windows-based systems.

  • COB_SUNSTUDIO12=[Y/N]

    Default is: N

    On sun SPARC Solaris, when using C compiler Sun Studio 12. you must set the runtime environment variable COB_SUNSTUDIO12 to Y to avoid receiving the warning:

    cc: Warning: -xarch=generic64 is deprecated, use -m64 to create 64-bit programs

    This environment variable setting is required when creating 64-bit programs. Otherwise, 4-byte structure alignments could cause your program to abort at runtime with the error:

    Bus Error (core dumped)

  • COBCPY <directory list>

    Designates colon ':'-separated list of pathes (Unix,Linux) or semi-colon ';'-separated list of pathes (Windows) where cobc looks for COPY files.

  • COBCTMP=<directory>

    Default is /tmp on UNIX/Linux-based systems and the local user's AppData\Local\Temp directory on Windows-based systems.

    Designates the directory where temporary files are stored.

    Note

    The default TMPDIR setting is returned in the command cobc -V. When compiling with the -save-temps compiler flag, temporary files are stored in the current directory.

  • COBITOPT=[string of command-line compiler flags]

    Stores command-line compiler flags, for use with cobc. COBITOPT is designed to be compatible with the MF environment variable COBOPT.

  • COBOPT=[string of command-line compiler flags]

    Stores command-line compiler flags, for use with cobmf. COBOPT is designed to be compatible with the MF environment variable COBOPT.

  • COBOLITDIR=<directory>

    Default is /opt/COBOL-it on UNIX/Linux-based systems and C:\COBOL\COBOLIT on Windows-based systems.

    Names the directory in which COBOL-IT is installed.

  • TMPDIR or TMP=<directory>

    Default is /tmp on UNIX/Linux-based systems and the local user's AppData\Local\Temp directory on Windows-based systems.

    Designates the directory where temporary files are stored.

    Note

    The default TMPDIR setting is returned in the command cobc -V.
    When compiling with the -save-temps compiler flag, temporary files are stored in the current directory.

Back to top