-o

Purpose

Names the executable program or shared library xxx, where xxx is any name. If the -o option is not used, the name of the executable module defaults to a.out. This option applies only to linking.

Syntax

Read syntax diagramSkip visual syntax diagram-opath

Parameters

path

When you are using the option to compile from source files, path can be the name of a file or directory. The path can be a relative or absolute path name. When you are using the option to link from object files, path must be a file name. If path is the name of an existing directory, files that are created by the compiler are placed into that directory. If path is not an existing directory, path is the name of the file that is produced by the compiler. See below for examples

Defaults

If you specify the -c option, an output object file, file_name.o, is produced for each input file. The linker is not invoked, and the object files are placed in your current directory. All processing stops at the completion of the compilation. The compiler gives object files a .o suffix, for example, file_name.o, unless you specify the -o option, giving a different suffix or no suffix at all.

Usage

If you use the -c option with -o together and the path is not an existing directory, you can compile only one source file at a time. In this case, if more than one source file name is listed in the compiler invocation, the compiler issues a warning message and ignores -o.

Examples

To compile myprogram.cbl so that the resulting executable is called myaccount, assuming that no directory with name myaccount exists, enter:

cob2 myprogram.cbl -o myaccount
To compile test.cbl to an object file only and name the object file new.o, enter:
cob2 test.cbl -c -o new.o

Related references