SlideShare a Scribd company logo
1 of 11
C++ Compilation Process
Topics
1. Compilation Flow
2. Pre-processing
3. Compilation
4. Assembler
5. Linking (static or dynamic)
6. Questions ?
Program.cpp
Pre-processing
Program.ii
Compilation
Program.s
Assembly
Program.o
Linking
Executable
or ELF
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
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
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
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
Command to view the ELF
> objdump –x srcfile.o
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)
Command to view the ELF
> readelf –a execfile
C++ compilation process

More Related Content

What's hot

file handling c++
file handling c++file handling c++
file handling c++
Guddu Spy
 

What's hot (20)

Intro to c++
Intro to c++Intro to c++
Intro to c++
 
file handling c++
file handling c++file handling c++
file handling c++
 
C Programming Unit-5
C Programming Unit-5C Programming Unit-5
C Programming Unit-5
 
Jdbc Ppt
Jdbc PptJdbc Ppt
Jdbc Ppt
 
Windowforms controls c#
Windowforms controls c#Windowforms controls c#
Windowforms controls c#
 
arrays and pointers
arrays and pointersarrays and pointers
arrays and pointers
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
Cursors
CursorsCursors
Cursors
 
Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())Memory Management C++ (Peeling operator new() and delete())
Memory Management C++ (Peeling operator new() and delete())
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 
Methods in C#
Methods in C#Methods in C#
Methods in C#
 
Polymorphism Using C++
Polymorphism Using C++Polymorphism Using C++
Polymorphism Using C++
 
INLINE FUNCTION IN C++
INLINE FUNCTION IN C++INLINE FUNCTION IN C++
INLINE FUNCTION IN C++
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Exception Handling in C#
Exception Handling in C#Exception Handling in C#
Exception Handling in C#
 

Similar to C++ compilation process

LOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfLOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdf
Thninh2
 

Similar to C++ compilation process (20)

Machine Understandable code
Machine Understandable codeMachine Understandable code
Machine Understandable code
 
Autoconf&Automake
Autoconf&AutomakeAutoconf&Automake
Autoconf&Automake
 
Build process in ST Visual Develop
Build process in ST Visual DevelopBuild process in ST Visual Develop
Build process in ST Visual Develop
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
Gnu build system
Gnu build systemGnu build system
Gnu build system
 
Exploring the Xcode Build Process
Exploring the Xcode Build Process Exploring the Xcode Build Process
Exploring the Xcode Build Process
 
CodeIgniter Lab
CodeIgniter LabCodeIgniter Lab
CodeIgniter Lab
 
Embedded C - Lecture 1
Embedded C - Lecture 1Embedded C - Lecture 1
Embedded C - Lecture 1
 
Lecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdfLecture 1.2 Basics of a typical C++ Environment.pdf
Lecture 1.2 Basics of a typical C++ Environment.pdf
 
LOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfLOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdf
 
introduction of c langauge(I unit)
introduction of c langauge(I unit)introduction of c langauge(I unit)
introduction of c langauge(I unit)
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptx
 
Protein Modeling using MODELLER
Protein Modeling using MODELLERProtein Modeling using MODELLER
Protein Modeling using MODELLER
 
C Programming Compilation Process.pdf
C Programming Compilation Process.pdfC Programming Compilation Process.pdf
C Programming Compilation Process.pdf
 
TDC2016POA | Trilha Cloud Computing - Source-to-image - How to transform any ...
TDC2016POA | Trilha Cloud Computing - Source-to-image - How to transform any ...TDC2016POA | Trilha Cloud Computing - Source-to-image - How to transform any ...
TDC2016POA | Trilha Cloud Computing - Source-to-image - How to transform any ...
 
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
Embedded Systems: Lecture 13: Introduction to GNU Toolchain (Build Tools)
 
C compilation process
C compilation processC compilation process
C compilation process
 
Introduction to cython
Introduction to cythonIntroduction to cython
Introduction to cython
 
Basics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptxBasics of C Lecture 2[16097].pptx
Basics of C Lecture 2[16097].pptx
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptx
 

More from Rahul Jamwal (6)

Process & Mutlithreading
Process & MutlithreadingProcess & Mutlithreading
Process & Mutlithreading
 
Searching & Sorting Algorithms
Searching & Sorting AlgorithmsSearching & Sorting Algorithms
Searching & Sorting Algorithms
 
Data Structures
Data StructuresData Structures
Data Structures
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory Management
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
 
C++ shared libraries and loading
C++ shared libraries and loadingC++ shared libraries and loading
C++ shared libraries and loading
 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

C++ compilation process

  • 2. Topics 1. Compilation Flow 2. Pre-processing 3. Compilation 4. Assembler 5. Linking (static or dynamic) 6. Questions ?
  • 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
  • 8. 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)
  • 10. Command to view the ELF > readelf –a execfile