Common options format for gcc/g++ commands (option interpretation)
-o file specifies the output file name, which is not required when compiling to the target code. If file is not specified, the default file name is a.out.
-C Build target file only, not link
-m486 code optimization for 486.
-o0 is not optimized for processing.
-O or-o1 optimization generates code.
-o2 further optimization.
-o3 is further optimized than-O2, including the inline function.
-W turns off all warnings and does not recommend using this item
-wall allows all useful warnings that GCC can provide, or w (warning) to mark specified warnings
-werror convert all warnings to errors to abort the compilation process when a warning occurs
-MM output a make-compatible related list
-V Displays the commands used in each step of the compilation process
-E only runs the C precompiled compiler.
-shared generate a shared destination file. Typically used when building a shared library.
-static linking static libraries, i.e. performing static links
-lfoo linking a function library named Libfoo
-G contains standard debug information in an executable program
-GGDB contains only GNU debugger in the executable program to make the other up to two is information
-O Optimized compiled code
-on specifies that the level of code optimization is n,o<=n<=3
-ansi supports the standard syntax of Ansi/iso C, removing portions of the GNU syntax extension that conflict with the standard (but this option does not guarantee the generation of ANSI-compatible code) This option will prohibit certain features of GNU C, such as ASM or typeof keywords.
-pedantic allows all warnings listed in the Ansi/iso C standard to be issued
-errors allows all errors listed in the Ansi/iso C standard to be issued
-traditional supports Kernighan & Ritchie C syntax (such as defining functions with legacy syntax); If you don't know what this option means, it doesn't matter.
-idirectory specifies additional header file search paths for directory.
-ldirectory Specifies additional library search paths for directory.
-dfoo=bar defines the preprocessing macro foo at the command line with a value of BAR
-idirname add dirname to the search directory list in the header file
-ldirname adds dirname to the list of search directories in the library file, by default GCC only links the shared library
-DMACRO defines macro macros with the string "1".
-DMACRO=DEFN defines macro macros with the string "DEFN".
-umacro cancels the definition of macro macros.
Compile CPP files with g++ if you compile the C + + source file with GCC, the following option is used:-lstdc++, otherwise, a file compilation with C + + operation will fail.
Common options for the gcc/g++ command