Source: HTTP://MAN.LINUXDE.NET/GCC
Grammar
GCC Options Parameters
Options
-o: Specifies the generated output file;-E: performs only compile preprocessing;-S: Converts C code to assembly code;-Wall: Displays a warning message;-C: Only the compilation operation is performed. The connection operation is not performed.
Parameters
C Source file: Specifies the C language source code file.
Suppose the source program file is named TEST.c
No option to compile links
gcc test.c
Preprocess, assemble, compile, and link test.c into an executable file. The output file is not specified here, and the default output is a.out.
Option-O
gcc test.c-o test
Preprocess, assemble, compile, and link test.c to form the executable test. The-o option is used to specify the file name of the output file.
Option-E
gcc -e test.c-o test.i
The test.c preprocessing output test.i file.
Option-S
gcc -S TEST.I
Assembles the preprocessed output file test.i into a test.s file.
Option-C
gcc -C TEST.S
The assembly output file Test.s compiled output TEST.O file.
No option link
gcc test.o-o test
Link the compiled output file TEST.O to the final executable test.
Option-O
gcc -o1 test.c-o test
Compile the program using the Compile Optimization level 1. The higher the level, the better the optimization effect, but the longer the compilation time.
Methods of compiling multi-source files
If you have more than one source file, there are basically two ways to compile: Suppose there are two source files for TEST.c and TESTFUN.C
Compiling multiple files together
gcc testfun.c test.c-o test
Compile testfun.c and test.c separately and link them to the test executable file.
Compile each source file separately, and then link to the target file for the post-compilation output.
gcc -c testfun.c #将testfun. C compiled into TESTFUN.Ogcc -c test.c #将test. C compiled into TEST.Ogcc -o testfun.o test.o-o test #将testfun. O and TEST.O link to test
The above two methods compare, the first method compiles all the files need to recompile, and the second method can only recompile modified files, unmodified files do not have to recompile.
From: HTTP://MAN.LINUXDE.NET/GCC
"Linux" gcc command