Noeud:Default File Renaming, Noeud « Next »:Verbose Output, Noeud « Previous »:Defining Constants, Noeud « Up »:Useful GCC Options
To replace the name of any created default file (for example
a.out from a full compilation, or source.s from using
-S command with a file called source.c, etc.), use
the -o option:
gcc source.c -o prog
produces an executable file name prog after compiling the source file
source.c. This replaces the default executable file named
a.out.
Use the -o option in any of the stages which produce some
output file to redirect the default naming conventions (.o,
.s etc.) to any file name specified by the -o flag. Thus,
gcc source.c -S -o newFile1
and
gcc source.c -c -o newFile2
will produce a file named newFile1 and newFile2 respectively
instead of the default source.s and source.o.