-o

Purpose

Specifies a name for the output object, assembler, executable, or preprocessed file.

Syntax

Read syntax diagramSkip visual syntax diagram  -o path

Defaults

See Types of output files for the default file names and suffixes produced by different phases of compilation.

Parameters

path
When you are using the option to compile from source files, path can be the name of a file a relative or absolute path name. When you are using the option to link from object files, path must be a file name.

You cannot specify a file name with a C or C++ source file suffix (.C, .c, or .cpp), such as myprog.c; this results in an error and neither the compiler nor the linker is invoked.

Usage

If you use the -c option with -o , you can compile only one source file at a time. In this case, if more than one source file name is specified, the compiler issues a warning message and ignores -o.

The -E, and -fsyntax-only options override the -o option.

Predefined macros

None.

Examples

To compile myprogram.c so that the resulting executable is called myaccount , enter:
ibm-clang myprogram.c -o myaccount
To compile test.c to an object file only and name the object file new.o, enter:
ibm-clang test.c -c -o new.o

Related information