Linux study Note 5: gcc program compiling gcc (gnu c Compiler) in Linux is a platform Compiler with powerful functions released by GNU, it can compile executable programs on a variety of hardware platforms, learning and mastering gcc is necessary, because gcc will accompany our entire linux learning and development process. Gcc can reduce c, c ++, and assembler compilation links to executable files. Note that the executable files in linux do not have a uniform suffix. The system distinguishes them from the file attributes, which is different from that in windows. Can the source file of gcc be independent of the file suffix? The answer is no. gcc uses a suffix to differentiate the type of the input file, for example :. c ,. a (library file consisting of the target file ),. C ,. cc ,. cxx (C ++ source code file ),. h (header file ),. I (C source code files that have been preprocessed ),. ii (c ++ source code files that have been preprocessed ),. o (the target file after compilation ),. s (Assembly source code file ),. S (Assembly source files that have been precompiled); the gcc compilation process can be divided into four stages: preprocessing, compilation, assembly, and link. Www.2cto.com let's look at a simple example: gcc common compilation options: 1. -o (small o) specifies the executable file name after compilation. The default value is XXX. out 2. -c is only compiled and will not be connected. o file, not executable 3. -g: compile a program that can be debugged. If you need to debug the program,-g must be included in the compilation, and the generated file will be much larger. -O and-O2 optimize the compilation link process. -I (large I) such as-I/home/a specified plus header file directory, you can also directly put your own header file under/usr/include/www.2cto.com 6. -L specifies the path of the database, which is the same as-I 7. -static links integrate libraries into programs to form an executable file. Compared with dynamic libraries, dynamic libraries only call the function library dynamically at runtime. Static links are a waste of space and time-consuming dynamic links. Dynamic Links are used by default, but static links are performed only when the-static option is added during compilation. 8.-Wall: generate all warning information, while-w does not generate any warning information. 9.-D is equivalent to # define for macro definition. For example, gcc-DYES hello. c-o hello defines a macro named "YES", stewen_001.