SlideShare a Scribd company logo
1 of 17
Download to read offline
GCC(GNU Compiler Collection)
         Tool Kit



         Linux Users Group, JMI

An overview of GNU Compiler Collection and
         its use for compiling C, C++

           By: Saleem A. Ansari
The Free Software Compiler
          An Introduction to GCC
   Virtually all other open software is based on it at
    some level or another. Even other languages,
    such as Perl and Python, are written in C, which
    is compiled by the GNU compiler.
   This piece of software is more fundamental to
    the entire free software movement than any
    other. In fact, without it or something like it,
    there would be no free software movement. Lin-
    ux is possible because of GCC.
GCC is a product of the GNU
                  Project.
   The fundamental language of GCC is C. The en-
    tire compiler system began as a C compiler and,
    over time, the other languages were added to it.
   C++ Was the First Addition. Now can compile
    C++, Objective-C, Java, Ada, Fortran ...
   The GCC set of compilers runs on many plat-
    forms. We can do multi-platform compilation us-
    ing the same machine. (Alpha, HPPA, Intel x86,
    MIPS, PowerPC, Sparc)
GCC Components
   cc1: The actual C compiler.
   cc : A version of gcc that sets the default lan-
    guage to C and automatically includes the
    standard C libraries when linking.
   cc1plus : The actual C++ compiler.
   g++ / c++ : A version of gcc that sets the default
    language to C++.
   jc1: The actual Java compiler.
   gcj The driver program used to compile Java.
   gcc: The driver program.
GCC Components contd.
   as : The GNU assembler. It is really a family of
    assemblers because it can be compiled to work
    with one of several different platforms. This pro-
    gram is part of the binutils package.
   gdb : The GNU debugger, which can be used to
    examine the values and actions inside a pro-
    gram while it is running.
   Other tools : gprof (profiler), ld(linker),
    ar(archive), make, nm, objcopy, objdump, ranlib,
    strip ...
Developing Software using GCC

   You need a text editor: gedit, kedit, vi
    emacs, joe, nedit etc.
   You need to learn atleast one of the lan-
    guages supported by GCC: C, C++, Java,
    Fortran etc.
   You need the GCC Toolkit Installed on the
    system itself
   get-set-go...
The famous C program
/*hello.c*/
#include<stdio.h>
int main()
{
     printf(“Hello GCCn”);
     return 0;
}

Compilation:
cc ­c hello.c
cc ­o hello hello.o
./hello
The famous program in C++
/*hello.cpp*/
#include<iostream>
using namespace std;
int main(void)
{
      cout << “Hello GCC” << endl;
      return 0;
}

Compilation:
c++ ­c hello.cpp
c++ ­o hello hello.o
./hello
Command Line Options
   -c compile and produce object
    code
   -o name of translated code file
   -l specify library
   -I specify include directory
   -Wall show all errors
   -std=__ assume the specified
    standard
   -v give verbose output
   -s, -S result in assembly code
    production
   -O1, O2, -O3 Optimization Levels
Yet another simple example. Illegal
         memory access!!
 #include<stdio.h>
 int main()
 {
 char *str=”abc”;
 str[0]=’d’;
 str[1]=’e’;
 str[2]=’f’;
 puts(str);
 return 0;
 }
Here comes the debugger

   Use the GCC command line switch -g or
    -ggdb to incorporate debugging information
    into the object code
   Invoke the gdb and fire!!
Multiple Files: A simple example

/*mystring.c*/
#include<string.h>               /*mystring.h*/
int palindrome(char s[])         int palindrome(char s[]);
{
      int l=strlen(s)-1;
      int i=0;
      while(i<l)
            if(s[i++]!=s[l--])
                   return 0;
      return 1;
}
/*mystringtest.c*/
                        continued...
#include<stdio.h>
#include "mystring.h"
int main()
{
      char str[50];
      puts("Enter a string:");
      gets(str);
      if(palindrome(str))
             printf("Its a palindrome");
      else
             printf("Its not a palindrome");
      return 0;
}
MAKE indeed is a boon
MAKEFILE
--------------------------------------------------------------------------
CC=gcc
CFLAGS=-Wall -g
all: mystring.a test
test: mystring.a
        $(CC) $(CFLAGS) -c mystringtest.c
        $(CC) $(CFLAGS) -o test mystringtest.o mystring.a
clean:
        rm -f test mystringtest.o mystring.o mystring.a
mystring.a: mystring.o
        ar cvr mystring.a mystring.o
        ranlib mystring.a
mystring.o:
        $(CC) $(CFLAGS) -c mystring.c
Compiling a complete software




 MPlayer as an example demonstration
For further information

   Manpages of gcc, make, gdb, nm, obj-
    dump, objcopy...
   Info pages of binutils
Thats all for now!




      Thanx

More Related Content

What's hot

How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)Sławomir Zborowski
 
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
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkAlexey Smirnov
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDBkyaw thiha
 
C++ compilation process
C++ compilation processC++ compilation process
C++ compilation processRahul Jamwal
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Yandex
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programmingAlpana Gupta
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDBDavid Khosid
 
LLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationLLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationVivek Pansara
 
Claire protorpc
Claire protorpcClaire protorpc
Claire protorpcFan Robbin
 
Turbo C Compiler Reports
Turbo C Compiler Reports Turbo C Compiler Reports
Turbo C Compiler Reports Sunil Kumar R
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...Mickael Istria
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handoutSuraj Kumar
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c languagefarishah
 

What's hot (20)

GCC compiler
GCC compilerGCC compiler
GCC compiler
 
How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)How it's made: C++ compilers (GCC)
How it's made: C++ compilers (GCC)
 
introduction of c langauge(I unit)
introduction of c langauge(I unit)introduction of c langauge(I unit)
introduction of c langauge(I unit)
 
C compilation process
C compilation processC compilation process
C compilation process
 
GEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions FrameworkGEM - GNU C Compiler Extensions Framework
GEM - GNU C Compiler Extensions Framework
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
Debugging With GNU Debugger GDB
Debugging With GNU Debugger GDBDebugging With GNU Debugger GDB
Debugging With GNU Debugger GDB
 
C++ compilation process
C++ compilation processC++ compilation process
C++ compilation process
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
Разработка кросс-платформенного кода между iPhone &lt; -> Windows с помощью o...
 
Gnu debugger
Gnu debuggerGnu debugger
Gnu debugger
 
GCC RTL and Machine Description
GCC RTL and Machine DescriptionGCC RTL and Machine Description
GCC RTL and Machine Description
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Advanced Debugging with GDB
Advanced Debugging with GDBAdvanced Debugging with GDB
Advanced Debugging with GDB
 
LLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time OptimizationLLVM Compiler - Link Time Optimization
LLVM Compiler - Link Time Optimization
 
Claire protorpc
Claire protorpcClaire protorpc
Claire protorpc
 
Turbo C Compiler Reports
Turbo C Compiler Reports Turbo C Compiler Reports
Turbo C Compiler Reports
 
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
IDE as a Front-end and Fast time-to-market language support in Eclipse IDE re...
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handout
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 

Viewers also liked

Viewers also liked (8)

HRM - PM in GCC
HRM - PM in GCCHRM - PM in GCC
HRM - PM in GCC
 
Introduction to Perl - Day 1
Introduction to Perl - Day 1Introduction to Perl - Day 1
Introduction to Perl - Day 1
 
Gcc opt
Gcc optGcc opt
Gcc opt
 
MinGw Compiler
MinGw CompilerMinGw Compiler
MinGw Compiler
 
Principles of compiler design
Principles of compiler designPrinciples of compiler design
Principles of compiler design
 
NetBeans para Java, C, C++
NetBeans para Java, C, C++NetBeans para Java, C, C++
NetBeans para Java, C, C++
 
Deep C
Deep CDeep C
Deep C
 
GCC
GCCGCC
GCC
 

Similar to GNU Compiler Collection - August 2005

ICT1002-W8-LEC-Introduction-to-C.pdf
ICT1002-W8-LEC-Introduction-to-C.pdfICT1002-W8-LEC-Introduction-to-C.pdf
ICT1002-W8-LEC-Introduction-to-C.pdfssuser33f16f
 
Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docxeugeniadean34240
 
Golang execution modes
Golang execution modesGolang execution modes
Golang execution modesTing-Li Chou
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application DevelopmentRamesh Prasad
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docMayurWagh46
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxNEHARAJPUT239591
 

Similar to GNU Compiler Collection - August 2005 (20)

C introduction by piyushkumar
C introduction by piyushkumarC introduction by piyushkumar
C introduction by piyushkumar
 
1 c introduction
1 c introduction1 c introduction
1 c introduction
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
ICT1002-W8-LEC-Introduction-to-C.pdf
ICT1002-W8-LEC-Introduction-to-C.pdfICT1002-W8-LEC-Introduction-to-C.pdf
ICT1002-W8-LEC-Introduction-to-C.pdf
 
C Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.comC Programming Tutorial - www.infomtec.com
C Programming Tutorial - www.infomtec.com
 
lab1-ppt.pdf
lab1-ppt.pdflab1-ppt.pdf
lab1-ppt.pdf
 
C programming first_session
C programming first_sessionC programming first_session
C programming first_session
 
C programming first_session
C programming first_sessionC programming first_session
C programming first_session
 
GCC
GCCGCC
GCC
 
Hidden Dragons of CGO
Hidden Dragons of CGOHidden Dragons of CGO
Hidden Dragons of CGO
 
Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and Golang
 
C++Basics2022.pptx
C++Basics2022.pptxC++Basics2022.pptx
C++Basics2022.pptx
 
Csdfsadf
CsdfsadfCsdfsadf
Csdfsadf
 
C
CC
C
 
C
CC
C
 
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
20145-5SumII_CSC407_assign1.htmlCSC 407 Computer Systems II.docx
 
Golang execution modes
Golang execution modesGolang execution modes
Golang execution modes
 
Advance Android Application Development
Advance Android Application DevelopmentAdvance Android Application Development
Advance Android Application Development
 
Introduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).docIntroduction-to-C-Part-1 (1).doc
Introduction-to-C-Part-1 (1).doc
 
Introduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptxIntroduction-to-C-Part-1.pptx
Introduction-to-C-Part-1.pptx
 

More from Saleem Ansari

Web Application Development
Web Application DevelopmentWeb Application Development
Web Application DevelopmentSaleem Ansari
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaSaleem Ansari
 
Lessons I learnt from Linux Asia 2006
Lessons I learnt from Linux Asia 2006Lessons I learnt from Linux Asia 2006
Lessons I learnt from Linux Asia 2006Saleem Ansari
 
Linx Asia 2006 Experience
Linx Asia 2006 ExperienceLinx Asia 2006 Experience
Linx Asia 2006 ExperienceSaleem Ansari
 
Introduction to Qt Designer
Introduction to Qt DesignerIntroduction to Qt Designer
Introduction to Qt DesignerSaleem Ansari
 
Introduction to Free and Open Source Software - August 2005
Introduction to Free and Open Source Software - August 2005Introduction to Free and Open Source Software - August 2005
Introduction to Free and Open Source Software - August 2005Saleem Ansari
 
JMILUG Introduction - 2007
JMILUG Introduction - 2007JMILUG Introduction - 2007
JMILUG Introduction - 2007Saleem Ansari
 
TorqueBox at GNUnify 2012
TorqueBox at GNUnify 2012TorqueBox at GNUnify 2012
TorqueBox at GNUnify 2012Saleem Ansari
 
Fedora Embedded at foss.in 2010
Fedora Embedded at foss.in 2010Fedora Embedded at foss.in 2010
Fedora Embedded at foss.in 2010Saleem Ansari
 

More from Saleem Ansari (10)

Web Application Development
Web Application DevelopmentWeb Application Development
Web Application Development
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Lessons I learnt from Linux Asia 2006
Lessons I learnt from Linux Asia 2006Lessons I learnt from Linux Asia 2006
Lessons I learnt from Linux Asia 2006
 
Linx Asia 2006 Experience
Linx Asia 2006 ExperienceLinx Asia 2006 Experience
Linx Asia 2006 Experience
 
Introduction to Qt Designer
Introduction to Qt DesignerIntroduction to Qt Designer
Introduction to Qt Designer
 
Linux Asia 2006
Linux Asia 2006Linux Asia 2006
Linux Asia 2006
 
Introduction to Free and Open Source Software - August 2005
Introduction to Free and Open Source Software - August 2005Introduction to Free and Open Source Software - August 2005
Introduction to Free and Open Source Software - August 2005
 
JMILUG Introduction - 2007
JMILUG Introduction - 2007JMILUG Introduction - 2007
JMILUG Introduction - 2007
 
TorqueBox at GNUnify 2012
TorqueBox at GNUnify 2012TorqueBox at GNUnify 2012
TorqueBox at GNUnify 2012
 
Fedora Embedded at foss.in 2010
Fedora Embedded at foss.in 2010Fedora Embedded at foss.in 2010
Fedora Embedded at foss.in 2010
 

Recently uploaded

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 

Recently uploaded (20)

ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

GNU Compiler Collection - August 2005

  • 1. GCC(GNU Compiler Collection) Tool Kit Linux Users Group, JMI An overview of GNU Compiler Collection and its use for compiling C, C++ By: Saleem A. Ansari
  • 2. The Free Software Compiler An Introduction to GCC  Virtually all other open software is based on it at some level or another. Even other languages, such as Perl and Python, are written in C, which is compiled by the GNU compiler.  This piece of software is more fundamental to the entire free software movement than any other. In fact, without it or something like it, there would be no free software movement. Lin- ux is possible because of GCC.
  • 3. GCC is a product of the GNU Project.  The fundamental language of GCC is C. The en- tire compiler system began as a C compiler and, over time, the other languages were added to it.  C++ Was the First Addition. Now can compile C++, Objective-C, Java, Ada, Fortran ...  The GCC set of compilers runs on many plat- forms. We can do multi-platform compilation us- ing the same machine. (Alpha, HPPA, Intel x86, MIPS, PowerPC, Sparc)
  • 4. GCC Components  cc1: The actual C compiler.  cc : A version of gcc that sets the default lan- guage to C and automatically includes the standard C libraries when linking.  cc1plus : The actual C++ compiler.  g++ / c++ : A version of gcc that sets the default language to C++.  jc1: The actual Java compiler.  gcj The driver program used to compile Java.  gcc: The driver program.
  • 5. GCC Components contd.  as : The GNU assembler. It is really a family of assemblers because it can be compiled to work with one of several different platforms. This pro- gram is part of the binutils package.  gdb : The GNU debugger, which can be used to examine the values and actions inside a pro- gram while it is running.  Other tools : gprof (profiler), ld(linker), ar(archive), make, nm, objcopy, objdump, ranlib, strip ...
  • 6. Developing Software using GCC  You need a text editor: gedit, kedit, vi emacs, joe, nedit etc.  You need to learn atleast one of the lan- guages supported by GCC: C, C++, Java, Fortran etc.  You need the GCC Toolkit Installed on the system itself  get-set-go...
  • 7. The famous C program /*hello.c*/ #include<stdio.h> int main() { printf(“Hello GCCn”); return 0; } Compilation: cc ­c hello.c cc ­o hello hello.o ./hello
  • 8. The famous program in C++ /*hello.cpp*/ #include<iostream> using namespace std; int main(void) { cout << “Hello GCC” << endl; return 0; } Compilation: c++ ­c hello.cpp c++ ­o hello hello.o ./hello
  • 9. Command Line Options  -c compile and produce object code  -o name of translated code file  -l specify library  -I specify include directory  -Wall show all errors  -std=__ assume the specified standard  -v give verbose output  -s, -S result in assembly code production  -O1, O2, -O3 Optimization Levels
  • 10. Yet another simple example. Illegal memory access!! #include<stdio.h> int main() { char *str=”abc”; str[0]=’d’; str[1]=’e’; str[2]=’f’; puts(str); return 0; }
  • 11. Here comes the debugger  Use the GCC command line switch -g or -ggdb to incorporate debugging information into the object code  Invoke the gdb and fire!!
  • 12. Multiple Files: A simple example /*mystring.c*/ #include<string.h> /*mystring.h*/ int palindrome(char s[]) int palindrome(char s[]); { int l=strlen(s)-1; int i=0; while(i<l) if(s[i++]!=s[l--]) return 0; return 1; }
  • 13. /*mystringtest.c*/ continued... #include<stdio.h> #include "mystring.h" int main() { char str[50]; puts("Enter a string:"); gets(str); if(palindrome(str)) printf("Its a palindrome"); else printf("Its not a palindrome"); return 0; }
  • 14. MAKE indeed is a boon MAKEFILE -------------------------------------------------------------------------- CC=gcc CFLAGS=-Wall -g all: mystring.a test test: mystring.a $(CC) $(CFLAGS) -c mystringtest.c $(CC) $(CFLAGS) -o test mystringtest.o mystring.a clean: rm -f test mystringtest.o mystring.o mystring.a mystring.a: mystring.o ar cvr mystring.a mystring.o ranlib mystring.a mystring.o: $(CC) $(CFLAGS) -c mystring.c
  • 15. Compiling a complete software MPlayer as an example demonstration
  • 16. For further information  Manpages of gcc, make, gdb, nm, obj- dump, objcopy...  Info pages of binutils
  • 17. Thats all for now! Thanx