-o

Pragma equivalent

None.

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. 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.

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 only compile 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.

The -P and -fsyntax-only (-qsyntaxonly) options override the -o option.

Predefined macros

None.

Examples

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

Related information



Voice your opinion on getting help information Ask IBM compiler experts a technical question in the IBM XL compilers forum Reach out to us