How to Use GCC/G++ compiler: Pre-Processing,Compiling,Assembling,Linking
Gcc
GCC (GNU Compiler Collection, GNU Compiler Suite), is a set of GNU developed by the programming language compiler. It is a free software released by the GPL and LGPL licenses and a key part of the GNU program and is the standard compiler for free Unix and Apple Mac OS X operating systems. GCC (especially the C language compiler) is also often considered a de facto standard for cross-platform compilers.
Usage
Example code: hello.c
Compile
In essence, the compilation process is divided into four stages, namely Preprocessing, Compilation, Assembly, and Linking.
Preprocessing
gcc’s -E option allows the compiler to stop after preprocessing and output the preprocessing results. In this case, the result of the preprocessing is to insert the contents of the stdio.h file into hello.c.
Compilation
-S Compile only; do not assemble or link
-o <file> Place the output into <file>
Assembly
Linking
The gcc connector is provided by gas and is responsible for linking the target file of the program to all the additional target files needed to eventually generate the executable file. Additional target files include static link libraries and dynamic link libraries.
For the hello.o generated in the previous section, connect it to the C standard input and output library, and finally generate the hello program
G++
Pre-Processing
Compiling
Assembling
Linking