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 (20)

SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Methods in java
Methods in javaMethods in java
Methods in java
 
Java GC
Java GCJava GC
Java GC
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Java Foundations: Methods
Java Foundations: MethodsJava Foundations: Methods
Java Foundations: Methods
 
Code optimization
Code optimizationCode optimization
Code optimization
 
SQLite database in android
SQLite database in androidSQLite database in android
SQLite database in android
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
Software testing lab manual
Software testing lab manualSoftware testing lab manual
Software testing lab manual
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Java Notes
Java NotesJava Notes
Java Notes
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Interface
InterfaceInterface
Interface
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Multithreading in java
Multithreading in javaMultithreading in java
Multithreading in java
 
Polymorphism in oop
Polymorphism in oopPolymorphism in oop
Polymorphism in oop
 
Javascript arrays
Javascript arraysJavascript arrays
Javascript arrays
 

Similar to C++ compilation process

Machine Understandable code
Machine Understandable codeMachine Understandable code
Machine Understandable codejanusathis
 
Autoconf&Automake
Autoconf&AutomakeAutoconf&Automake
Autoconf&Automakeniurui
 
Build process in ST Visual Develop
Build process in ST Visual DevelopBuild process in ST Visual Develop
Build process in ST Visual DevelopGourav Kumar
 
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 DianaKhersonskaia
 
CodeIgniter Lab
CodeIgniter LabCodeIgniter Lab
CodeIgniter LabLeo Nguyen
 
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.pdfMianSaeedAkbar1
 
LOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfLOSS_C11- Programming Linux 20221006.pdf
LOSS_C11- Programming Linux 20221006.pdfThninh2
 
introduction of c langauge(I unit)
introduction of c langauge(I unit)introduction of c langauge(I unit)
introduction of c langauge(I unit)Prashant Sharma
 
embeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxembeddedc-lecture1-160404055102.pptx
embeddedc-lecture1-160404055102.pptxsangeetaSS
 
Protein Modeling using MODELLER
Protein Modeling using MODELLERProtein Modeling using MODELLER
Protein Modeling using MODELLERSyed Lokman
 
C Programming Compilation Process.pdf
C Programming Compilation Process.pdfC Programming Compilation Process.pdf
C Programming Compilation Process.pdfAhmedAbdElGhafar17
 
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 ...tdc-globalcode
 
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)Ahmed El-Arabawy
 
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].pptxCoolGamer16
 
Build process ppt.pptx
Build process ppt.pptxBuild process ppt.pptx
Build process ppt.pptxSHIVANISRECECE
 

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

Process & Mutlithreading
Process & MutlithreadingProcess & Mutlithreading
Process & MutlithreadingRahul Jamwal
 
Searching & Sorting Algorithms
Searching & Sorting AlgorithmsSearching & Sorting Algorithms
Searching & Sorting AlgorithmsRahul Jamwal
 
C++ Memory Management
C++ Memory ManagementC++ Memory Management
C++ Memory ManagementRahul Jamwal
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory ManagementRahul Jamwal
 
C++ shared libraries and loading
C++ shared libraries and loadingC++ shared libraries and loading
C++ shared libraries and loadingRahul Jamwal
 

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

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
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.pdfkalichargn70th171
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
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.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
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 ...harshavardhanraghave
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
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 WorkerThousandEyes
 

Recently uploaded (20)

Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
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
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
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
 
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
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
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 ...
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
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
 

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