Download presentation
Presentation is loading. Please wait.
1
KYC - Know your compiler Introduction to GCC
2
Application Specific Software Operating System Kernel
The Operating System User 1 User General Purpose or Application Specific Software Operating System Kernel Computer Hardware User 2
3
What is GCC? GCC is the GNU Compiler Collection
Provides Compilers for: C C++ Objective C Fortran ADA Java
4
Basic steps in compilation
Pre-Process directives like #include [gcc -E filename.c] Compilation of the C Code to generate the assembly [gcc -S filename.c] Assembly Code to object file generation [gcc -c filename.c] Link the object code to generate the executable
5
Possible Outputs for C/C++ Programs
Complete processing: Executable files Libraries Partial processing: C/C++ Source files after preprocessing only Assembly code corresponding to a source file Object code corresponding to a C/C++ file
6
Step 1: Compiling a simple C Program
Syntax: gcc <filename.c> gcc HelloWorld.c Output: An executable called a.out To run: ./a.out Content of HelloWorld.c: #include<stdio.h> int main() { printf(“Hello World\n”); return 0; } ./a.out Hello World
7
Step 2: Compiling a simple C++ Program
Syntax: g++ <filename.cpp> g++ HelloWorld.cpp Output: An executable called a.out To run: ./a.out Content of HelloWorld.cpp: #include<iostream> using namespace std; int main() { cout<<“Hello World”<<endl; return 0; } ./a.out Hello World
8
Step 3: Providing the executable name
Extra option: -o Syntax: gcc <filename.c> -o <outputname> gcc HelloWorld.c -o myapp Output: An executable called outputname To run: ./outputname ./myapp Hello World
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.