1. GCC-E source_file.c
-E, only to pre-compile. Outputs precompiled results directly.
2. Gcc-s source_file.c
-S, only executes the conversion to the source code to the assembly code, and outputs the assembly code.
3. Gcc-c source_file.c
-C, only executes to compile, output destination file.
4. GCC (-e/s/c/) source_file.c-o output_filename
-O, specify the output file name, can be used with the above three kinds of tags.
The-o parameter can be omitted. In this case, the compiler uses the following default name output:
-E: Precompiled result will be output to standard output port (usually monitor)
-S: Generate assembly code named SOURCE_FILE.S
-C: Generates a target file named SOURCE_FILE.O.
No label condition: generates an executable named A.out.
5. Gcc-g source_file.c
-G to generate executable files for debugging, which can be run in gdb. Because the file contains debug information, it is inefficient and the file is much larger.
Here you can use the Strip command to re-delete the debug information in the file. This is to find that the generated files are even smaller than the normal compiled output, because strip has removed some of the extra information (such as function names) from the original normal compilation. Usage is strip a.out
6. Gcc-s source_file.c
-S, directly generates an executable file with the same effect as the strip (all symbolic information is removed).
7. Gcc-o source_file.c
-O (uppercase letter O), the compiler automatically optimizes the code to compile and output more efficient executables.
You can also follow the number to specify the optimization level after-O, such as:
Gcc-o2 source_file.c
The larger the number, the more optimized. But usually, the automatic thing is not too clever, too much optimization level may cause the generated file to produce a series of bugs. The general choice of 2;3 will be a certain risk.
8. Gcc-wall source_file.c
-W, which opens some additional warning (warning) information in the compilation. -wall all warning messages to the full.
9. GCC Source_file.c-l/path/to/lib-lxxx-i/path/to/include
-L, which specifies the library of functions to use, in this case the linker tries to link to a library named LIBXXX.A.
-L, which specifies the folder where the library is located, in this case the linker tries to search the/path/to/lib folder.
-I, which specifies the folder where the header files are located, in this case the precompiled attempt to search the/path/to/include folder.
See the GCC manual page for more information.
Several common commands used by the GCC compiler