SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado (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 a 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 a 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
 

Más de 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
 

Más de 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
 

Último

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Último (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

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