1 Introduction
GCC (GNU Compiler Collection, GNU Compiler set) is a programming language compiler developed by GNU. It is a set of Free Software issued with GPL and lgpl licenses in the GNU Compiler package.
The key part of the GNU program is the standard compiler for free UNIX-like and Mac OS X operating systems on Apple computers.
2. compilation process
2.1 The compilation involves four steps:
1. Pre-processing)
2. Compile (Compiling)
3. Assembly)
4. Link (linking)
2.2 The file suffixes and types involved in compilation are as follows:
. C: C language source code file
. A: library file consisting of the target file
. C,. cc or. 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 language source code file
. S: Pre-compiled assembly language source code file
2.3 The entire compilation process is shown in figure 2.1:
Fig 2.1
Iii. GCC commands
2.1 GCC command format:
GCC [Options] [filenames]
2.2 options:
-O [output_filename]: target file name
-C: Only. O is compiled.
-G: compile with debugging information. It is used for GDB debugging.
-O: optimized
-O2: more optimized
-I [include_folder_path]: add the target directory to the GCC standard header file directory.
Note: # include <>: Find files from the GCC standard header file directory, such as/usr/include/
Note: # include "":
Current Directory
-L [library_folder_path]: directory of the file to be added to the database
-L [lib_name]: reference the library file. The path must be added in the default library path or-l
-Static: static Library Link file
-Wall: generates all warning information.
-W: no warning information is generated.
-D: equivalent to define