KYC - Know your compiler Introduction to GCC

Slides:



Advertisements
Similar presentations
Technotronics GCECT '091 Decode C This is a C Programming event, where you will be given problems to solve using C only. You will be given a Linux system.
Advertisements

C++ Introduction.
C++ Language Fundamentals. 2 Contents 1. Introduction to C++ 2. Basic syntax rules 3. Declaring and using variables.
CPSC 441 TUTORIAL – JANUARY 16, 2012 TA: MARYAM ELAHI INTRODUCTION TO C.
CSE202: Lecture 1The Ohio State University1 Introduction to C++
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
1 CSSE 332 Course Introduction. Roll Call and Introductions Name (nickname) Name (nickname) Hometown Hometown Local Residence Local Residence Major Major.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
1 Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Software Lesson #1 CS1313 Spring Software Lesson 1 Outline 1.Software Lesson 1 Outline 2.What is Software? A Program? Data? 3.What are Instructions?
CS211 Data Structures Sami Rollins Fall 2004.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
CS 101 Problem Solving and Structured Programming in C Sami Rollins Spring 2003.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
C/C++ Compiling.
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.
1 CS 161 Introduction to Programming and Problem Solving Chapter 10 g++ Compiler Usage Herbert G. Mayer, PSU Status 10/21/2014.
1 uClinux course Day 3 of 5 The uclinux toolchain, elf format and ripping a “hello world”
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
Intro. to Game Programming Want to program a game?
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
Introduction to C Programming. A Brief History u Created by Dennis Ritchie at AT&T Labs in 1972 u Originally created to design and support the Unix operating.
1 C/C++ UM/MCSR. 2 Logging into the system using ssh Logging into the system from Windows: –Start the secure shell client: Start->Programs->SSH.
History of C and C++ C++ evolved from C ANSI C C++ “spruces up” C
CSE 2541 – Advanced C Programming Instructor: Yang Zhang
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Creating your first C++ program
Lecture 0 CIS 208 C Language Lab Wed. January 12, 2005.
Programming With C.
CSE 2541 – Advanced C Programming. Course info Prereq – CSE 2221 or CSE 222 Co-req – CSE 2231 Website
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
Compiling a C Program. Before we can begin we must open a telnet session to phobos. There are a number of ways to do this, but the easiest is to click.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
1 COMS 261 Computer Science I Title: C++ Fundamentals Date: September 05, 2005 Lecture Number: 4.
Introduction to C CMSC 104, Section 4 Richard Chang 1.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Principles of Programming Chapter 1: Introduction  In this chapter you will learn about:  Overview of Computer Component  Overview of Programming 
Department of Electronic & Electrical Engineering Introduction to C - The Development cycle. Why C? The development cycle. Using Visual Studio ? A simple.
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
First Compilation Rudra Dutta CSC Spring 2007, Section 001.
Computer Programming A simple example /* HelloWorld: A simple C program */ #include int main (void) { printf (“Hello world!\n”); return.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
 Prepared by: Eng. Maryam Adel Abdel-Hady
 Prepared by: Eng. Maryam Adel Abdel-Hady
Software Engineering Algorithms, Compilers, & Lifecycle.
C++ Programming Chapter 1 Programming & Programs.
Introduction to GCC Department of Radio Physics and Electronics ILug-Cal Introduction to GCC Department of Radio Physics and Electronics, Calcutta University.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Chapter 5: Preparing C Programs
Introduction to C Topics Compilation Using the gcc Compiler
How to Program.
UMBC CMSC 104 – Section 01, Fall 2016
How to Start Programming in Linux Environment
Engineering Problem Solving With C An Object Based Approach
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Programming Language Hierarchy, Phases of a Java Program
Computer Programming Techniques Semester 1, 1998
C Programming Language
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introduction to C Topics Compilation Using the gcc Compiler
مباني كامپيوتر و برنامه سازي
2008/09/29: Lecture 7 CMSC 104, Section 0101 John Y. Park
Your first C and C++ programs
Introduction to Programming - 1
Introduction to C Topics Compilation Using the gcc Compiler
EN Software Carpentry Python – A Crash Course Esoteric Sections Compiled Languages.
SPL – PS1 Introduction to C++.
Presentation transcript:

KYC - Know your compiler Introduction to GCC

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

What is GCC? GCC is the GNU Compiler Collection Provides Compilers for: C C++ Objective C Fortran ADA Java

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

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

Step 1: Compiling a simple C Program Syntax: gcc <filename.c> user@ws$ 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; } user@ws$ ./a.out Hello World user@ws$

Step 2: Compiling a simple C++ Program Syntax: g++ <filename.cpp> user@ws$ 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; } user@ws$ ./a.out Hello World user@ws$

Step 3: Providing the executable name Extra option: -o Syntax: gcc <filename.c> -o <outputname> user@ws$ gcc HelloWorld.c -o myapp Output: An executable called outputname To run: ./outputname user@ws$ ./myapp Hello World user@ws$