Compiling C/C++ Programs in Linux Lab 02 1. 2 اللهم علمنا ما ينفعنا،،، وانفعنا بما علمتنا،،، وزدنا علماً

Slides:



Advertisements
Similar presentations
An Introduction to Programming By :- Vishal Hirani B.Tech II year (CSE)
Advertisements

Programming Basic Concepts © Juhani Välimäki 2003.
Binghamton University CS-220 Spring 2015 Binghamton University CS-220 Spring 2015 The CS-220 Development Environment.
Threads Lab اللهم علمنا ما ينفعنا،،، وانفعنا بما علمتنا،،، وزدنا علماً
Two Broad Categories of Software
Three types of computer languages
Selecting a Cross Development Environment. Why do you need to select a CDE? Through out your career the target systems will change rapidly –Both the h/w.
Lecture 1 : January 2001 Dr. Andrew Paul Myers
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 4P. 1Winter Quarter Introduction to UNIX.
Linux Operating system
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Agenda What is Computer Programming? The Programming Process
Introduction to Java Tonga Institute of Higher Education.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Computational physics PY2050 Course Details:
Intro. to Game Programming Want to program a game?
CS413: Java Programming language Applications Applets
AS Computing Software definitions.
COSC513 Project Linux Features Instructor: Prof. Mort Anvari Student: Yingfeng Luo ID: #
Instructor: Tina Tian. About me Office: RLC 203A Office Hours: Wednesday 1:30 - 4:30 PM or .
CHAPTER FOUR COMPUTER SOFTWARE.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
Computing Fundamenatls CMSC 201 Computer Science I Penny Rheingans University of Maryland Baltimore County (with inspiration from previous 201 instructors.
Computer Engineering 1 nd Semester Dr. Rabie A. Ramadan 2.
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
Systems Software Operating Systems. What is software? Software is the term that we use for all the programs and data that we use with a computer system.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
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.
Introduction to Computer Application (IC) MH Room 517 Time : 7:00-9:30pm.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Welcome to CS323 Operating System lab 1 TA: Nouf Al-Harbi NoufNaief.net.
I Power Higher Computing Software Development Development Languages and Environments.
Chapter Three The UNIX Editors.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
AE6382 MinGW l The MinGW (Minimalist GNU for Windows) GNU compilers u C/C++ u Fortran 77 u Fortran 95 l Generate native Windows code l User Windows libraries.
 Programming - the process of creating computer programs.
INFORMATION SYSTEM – SOFTWARE TOPIC: GRAPHICAL USER INTERFACE.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
1 Overview of Programming Principles of Computers.
Chapter – 8 Software Tools.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
Programming C++ in Linux by various IDEs and editors by: Danial Khashabi Master: Dr.B.Taheri November 2008.
Chapter 3: Mastering Editors Chapter 3 Mastering Editors (Emacs)
Chapter 1: Introduction to Computers and Programming
History of C and basics of Programming
Fundamentals of Programming I Overview of Programming
Why don’t programmers have to program in machine code?
CSC227: Operating Systems
Computer Terms Review from what language did C++ originate?
Tools of the Trade
Writing, Compiling and Running a C program
Topics Introduction to Repetition Structures
System Programming and administration
Computer 4 JEOPARDY Bobbie, Sandy, Trudy.
Guide To UNIX Using Linux Third Edition
Computer Engineering 1nd Semester
Chapter 2 First Java Programs
COMPSCI 111 / 111G An introduction to practical computing
Unit# 8: Introduction to Computer Programming
Computer Science I CSC 135.
CSC 142 Introduction to Java [Reading: chapters 1 & 2]
Computer Terms Review from what language did C++ originate?
Chapter 1: Introduction to Computers and Programming
Presentation transcript:

Compiling C/C++ Programs in Linux Lab 02 1

2 اللهم علمنا ما ينفعنا،،، وانفعنا بما علمتنا،،، وزدنا علماً

Lab Objective To practice writing and compiling C/C++ programs in Linux 3

Three things are necessary for creating C programs: a text editor, a compilercompiler a C standard library. 4

A text editor A text editor is all that is needed to create the source code for a program in C or in any other language.source code A text editor is a program for writing and editing plain text. It differs from a word processor in that it does not manage document formatting (e.g., typefaces, fonts, margins and italics) or other features commonly used in desktop publishing. 5

A text editor C programs can be written using any of the many text editors that are available for Linux, such as vi, gedit, kedit or emacs. vi At least one text editor is built into every Unix-like operating system, and most such systems contain several. 6

A text editor To see if a specific text editor exists on the system, all that is necessary is to type its name on the command line (i.e., the all- text user interface) and then press the ENTER key.command lineuser interface If it exists, the editor will appear in the existing window if it is a command line editor, such as vi.window 7

A text editor It will open in a new window if it is a GUI (graphical user interface) editor such as gedit.GUI For example, to see if vi is on the system (it or some variation of it almost always is), all that is necessary is to type the following command and press the ENTER key: vicommand 8

A compiler A compiler is a specialized program that converts source code into machine language (also called object code or machine code) so that it can be understood directly by a CPU (central processing unit).object code An excellent C compiler is included in the GNU Compiler Collection (GCC), one of the most important components of most modern Linux distributions. GNU Compiler Collection 9

A compiler GNU is an on-going project by the Free Software Foundation (FSF) to create a complete, Unix-compatible, high performance and freely distributable computing environment. GNUfreely distributable All that is necessary to see if the GCC is already installed and ready to use is to type the following command and press the ENTER key: gcc 10

What is gcc/ g++? gcc and g++ are part of the GNU Compiler Collection (GCC) gcc is the "GNU" C Compiler, and g++ is the "GNU C++ compiler gcc and g++ are command line compilers; that is; they do not have a GUI. A compiler is a program that translates human readable source code into computer executable machine code. 11

C library A library is a collection of subprograms that any programmer can employ to reduce the amount of complex and repetitive source code that has to be written for individual programs. Every Unix-like operating system requires a C library. 12

Practice … Write the following program using any text editor and save it in a file called salam.C Note: C++ source code should be given one of the valid C++ file extensions ‘.cc’, ‘.cpp’, ‘.cxx’ or ‘.C’ 13 #include Using namespace std; int main() { cout<<"Assalmo Alikom\n"; return 0; }

… Practice The standard way to compile this program is with the following command: This command compiles salam.c into an executable program called salam that you run by typing the following at the command line: 14 $ g++ salam.C –o salam $./salam

Exercise 1)Execute the previous program 2)Write and compile another program, name it loop.C that only has an infinite loop like the following: 3)Execute the loop program in the background. 4)List all current processes and their assigned ID (PID). Write down the PID of the loop program. 15 for(;;);

??? ANY QUESTIONS ??? 16