4. 1. Expansion of Macros
2. Define code as per macro condition
3. Remove Comments
4. Inclusion of all the Header files
5. Command to generate file after Pre-processor
6. Check Header files Guided Macros
> g++ -E SourceFileName.cpp -o SourceFileName.ii
5. Compile the source code file using below command give output file shown as last lines
in fig.2
g++ -E -D_WIN32 srcfile.cpp -o srcfile.ii
6. 1. Do syntax checking.
All the compilation error w.r.t are caught here.
2. Code Optimization.
3. Generate Assembly Code.
4. Command to generate file after Compilation
g++ -S SourceFileName.cpp –o SourceFileName.s
7. Compiler call the assembler to convert the assembly source file with ‘.s’
extension into object file.
Command to generate object file after Assembler Operation
g++ -C SourceFileName.cpp –o SourceFileName.o
Command to view the ELF
> objdump –x srcfile.o
9. The compiler take all the required object file with ‘.o’ extension and covert it
into single binary executable or ELF (Executable and Linking File with
execution ‘.a’ or ‘.so’).
Command to generate executable file after Linking Operation
> g++ SourceFileName.cpp –o SourceFileName.out
> g++ mainCode.o –L. -libSrcCode.a –o mainbin (dynamic library linking)
> g++ mainSrc.o –L. -libSrcCode.so –o mainbin (static library linking)