Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does -c option do in GCC [closed]

Tags:

c

gcc

gdb

Does anyone know what does the -c flag do in gcc?

For example, what's the difference between

gcc -c output0.c
vs gcc output0.c

I know the second one makes a .a file but I don't know what a .a file is.

Also, what does -o do in

gcc output0.o -o output0

Is it just to name the output file right?

like image 337
Weadadada Awda Avatar asked Feb 06 '13 08:02

Weadadada Awda


1 Answers

-c

Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.

By default, the object file name for a source file is made by replacing the suffix .c, .i, .s, etc., with .o. Unrecognized input files, not requiring compilation or assembly, are ignored.

-o file

Place output in file file. This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code. If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.

More can be found in GCC Manual Page

like image 65
StarPinkER Avatar answered Sep 21 '22 22:09

StarPinkER