o
Option Type |
Default Value |
#pragma options |
C |
C++ |
-flag |
- |
- |
x |
x |
Syntax
-o file_spec
Purpose
Specifies an output location for the object, assembler, or executable files created by the
compiler. When the -o option is used during compiler invocation, file_spec
can be the name of either a file or a directory. When the -o option is
used during direct linkage-editor invocation, file_spec can only be the name of a
file.
Notes
When -o is specified as part of a complier invocation, file_spec
can be the relative or absolute path name of either a directory or a file.
- If file_spec is the name of a directory, files created by the compiler are
placed into that directory.
- If a directory with the name file_spec does not exist, the -o
option specifies that the name of the file produced by the compiler will be file_spec.
Otherwise, files created by the compiler will take on their default names. For example,
the following compiler invocation:
xlC test.c -c -o new.o
produces the object file new.o instead of test.o ,
and
xlC test.c -o new
produces the object file new instead of a.out
A file_spec with a C or C++ source file suffix (.C, .c,
or .i), such as my_text.c or bob.i, results in an error and neither the
compiler nor the linkage editor is invoked.
If you -c and -o together and the filespec
does not specify a directory, 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 -E, -P, and -qsyntaxonly options override the -ofilename
option.
Example
- To compile myprogram.c so that the resulting file is called myaccount,
assuming that no directory with name myaccount exists, enter:
xlC myprogram.c -o myaccount
If the directory myaccount does exist, the executable file produced by
the compiler is placed in the myaccount directory.
![](../images/ngrelr.gif)
List of Batch Compiler Options and Their Defaults
Options that Specify Linkage Options
Equivalent Batch Compile-Link and Incremental
Build Options