The process of compiling C++ source code consists of four stages:
- Preprocessing: In this stage, the source code is processed using a preprocessor and a preprocessed intermediate file is generated.
2. Compilation: At this stage, the preprocessed intermediate file is compiled into an object file expressed in assembly language.The generated files are usually intermediate files with
.i
or.ii
extensions such as HelloWorld.i or HelloWorld.ii.
3. Assembly (Assembling): At this stage, the assembler assembles the object files expressed in assembly language into machine-readable object files.The resulting file is usually an assembly language file with an extension of
.s
or , for example, HelloWorld.s or HelloWorld.asm..asm
4. Linking (Linking): At this stage, the linker links the various object files and library files to generate the final executable program.The generated file is an object file with
.o
or.obj
extension, eg HelloWorld.o or HelloWorld.obj.
The generated file is usually an executable file or a dynamic link library file with the extension of ,
.exe
or.dll
, such as HelloWorld.exe..so
Therefore, the combination of these four stages is also called "Preprocessing, Compilation, Assembly and Linking" (Preprocessing, Compilation, Assembly and Linking, referred to as PCAL).