Specifies an output location for the object, assembler, or executable files created by the compiler. When the -o option is used during compiler invocation, filespec can be the name of either a file or a directory. When the -o option is used during direct linkage-editor invocation, filespec can only be the name of a file.
>>- -o-- filespec----------------------------------------------><
When -o is specified as part of a compiler invocation, filespec can be the relative or absolute path name of either a directory or a file.
xlc test.c -c -o new.oproduces the object file new.o instead of test.o , and
xlc test.c -o newproduces the object file new instead of a.out, provided there is no directory also named new. Otherwise, the default object name a.out is used and placed in the new directory.
A filespec with a C or C++ source file suffix (.C, .c, .cpp, or .i), such as myprog.c or myprog.i, results in an error and neither the compiler nor the linkage editor is invoked.
If you use -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.
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 compiler produces the executable file a.out and places it in the myaccount directory.
Related information