Specifying the Output File with -o, -S

When compiling and linking a set of source files, you can use the -o or -S option to give the resulting file a name other than that of the first source or object file on the command line.

-Sfilename

Produce assembly file or directory for multiple assembly files; for example, -Smyprog, -Smydir\.

-ofilename

Produce object file or directory for multiple object files specified in filename.

-ofilename

Produce executable file or directory for multiple executable files specified in filename.

-map

Produce map file named file or directory for multiple files.

If you are processing a single file, you can use the -ofilename option to specify an alternate name for an object file (.o), an assembly file (.s) or an executable file. You can also use these options to override the default filename extensions: .o and .s.

Specifying File Name

IA-32 applications:

prompt>ifc -c -ofile.o x.f90

Itanium(TM)-based applications:

prompt>efc -c -ofile.o x.f90

-o assigns the name file.o to an output object file rather than the default (x.o)

-c directs the compiler to suppress linking.

In the next example, the command produces an executable file named outfile as a result of compiling and linking two source files.

IA-32 applications:

prompt>ifc -ooutfile file.f90 file2.f90

Itanium-based applications:

prompt>efc -ooutfile file.f90 file2.f90

Specifying Directory Name

When compiling one or more files, the argument of the -o and -S options can specify a directory name. To distinguish from file name, the argument must end in a dash or backslash (-) or (\) character, and it must specify an existing directory. In this case, the compiler will use the default convention in naming the executable, assembly, or object files produced, but the files will be placed in the directory specified by file.

In the example below, assume that obj_dir is an existing directory. The -o option causes the compiler to create the object files a.o, b.o, and c.o and place them in the directory obj_dir.

IA-32 applications:

prompt>ifc -oobj_dir- a.f90 b.f90 c.f90

Itanium-based applications:

prompt>efc -oobj_dir- a.f90 b.f90 c.f90

Do not enter a space between the option and the argument. You can specify different name arguments for each of the -o and -S options. The compiler does not remove objects that it produces, even when the compilation proceeds to the link phase.