17
1 CSCI 230 Computing-I CSCI 230 Computing-I Welcome to CSCI 230! Welcome to CSCI 230! Problem Solving using C Problem Solving using C

Lab Compiling Under Linux

Embed Size (px)

Citation preview

Page 1: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 1/17

11

CSCI 230

Computing-I

CSCI 230

Computing-I

Welcome to CSCI 230!Welcome to CSCI 230!

Problem Solving using CProblem Solving using C

Page 2: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 2/17

22

O bjectives for the LabO bjectives for the Lab

Learn problem solving strategiesLearn problem solving strategies

Achieve intermediate knowledge of CAchieve intermediate knowledge of CProgramming LanguageProgramming LanguageGain experience leveraging basic dataGain experience leveraging basic datastructuresstructuresGet an understanding of simple algorithmsGet an understanding of simple algorithms

Page 3: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 3/17

33

AgendaAgenda

E nvironment setupE nvironment setupLogin to PegasusLogin to Pegasus

E mailE mail

Introduction to UNIXIntroduction to UNIXUNIX files and directory structureUNIX files and directory structure

Basic UNIX commandsBasic UNIX commands

Page 4: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 4/17

44

AgendaAgenda

H ow to use a text editor H ow to use a text editor emacs editor emacs editor ---- basic commands basic commands

Create and compiler your first C program!Create and compiler your first C program!³ H ello world´ program³ H ello world´ programCompile using ³gcc´ compiler Compile using ³gcc´ compiler E xecuteE xecute

Page 5: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 5/17

55

Login to UNIXLogin to UNIX

User NameUser NameO ncourse usernameO ncourse username

PasswordPasswordO ncourse passwordO ncourse password

Page 6: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 6/17

66

Login (Cont¶d)Login (Cont¶d)

UNIX is case-sensitive !T he username and the password are in low er low er--casecase

If you are N OT able to logon then:Contact a Lab Instructor or Course Instructor

O nce you login for the first time, the system will prompt you to change the password«create a new

password and remember it

Page 7: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 7/17

77

Introduction to UNIXIntroduction to UNIX

UNIX is a multitasking operating systemUNIX is a multitasking operating systemthat manages the resources of a computer that manages the resources of a computer and provides a user interface.and provides a user interface.UNIX is case sensitive, which means, upper UNIX is case sensitive, which means, upper and lower case characters are treated asand lower case characters are treated asdifferent characters.different characters.T he UNIX machine for which you are givenT he UNIX machine for which you are givenan account is:an account is: pegasus.cs.iu pui.edu pegasus.cs.iu pui.edu

Page 8: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 8/17

88

A directory is a location to storeA directory is a location to storeinformation.information.

UNIX starts with a root directoryUNIX starts with a root directory//

/etc /home /usr /etc /home /usr

/bin /jsmith /tjones /local/bin /jsmith /tjones /local

T he UNIX Directory StructureT he UNIX Directory Structure

Page 9: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 9/17

99

T he UNIX PromptT he UNIX Prompt

login: jsmithlogin: jsmithPassword:Password:Last login: Mon Aug 22 08:42:33 from gatekeep.usagrouLast login: Mon Aug 22 08:42:33 from gatekeep.usagrou

Sun Microsystems Inc. Sun O S 5.8 Generic February 2000Sun Microsystems Inc. Sun O S 5.8 Generic February 2000

pegasus{jsmith}1: pegasus{jsmith}1:

Machine name

User name

Commandnumber

Page 10: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 10/17

1010

E ssential UNIX CommandsE ssential UNIX Commands

lsls-- list files in present working directorylist files in present working directory pwd pwd-- display present working directorydisplay present working directory

cdcd-- change directorychange directorycd .. Backup one directory levelcd .. Backup one directory level

lp (or lpr)lp (or lpr) -- print file to printer: print file to printer: Printer in SL251!Printer in SL251!

rmrm-- remove a fileremove a file

cpcp-- copy a filecopy a filemvmv-- move or rename a filemove or rename a filemkdir mkdir-- make a directorymake a directoryrmdir rmdir-- remove a directoryremove a directory

Page 11: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 11/17

1111

E mailE mail

All email correspondence should take placeAll email correspondence should take placethrough O ncourse.through O ncourse.

Page 12: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 12/17

1212

Class E -mail SubscriptionClass E -mail Subscription

Subscribe to the class email to receive mailSubscribe to the class email to receive mailsent to the entire class by instructors andsent to the entire class by instructors andother classmatesother classmatesSend mail to:Send mail to: [email protected]@cs.iupui.eduSubject: blank Subject: blank Body of Message:Body of Message:subscribe cs230subscribe cs230

Page 13: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 13/17

1313

PinePine

Y ou can practice subscribing from unix, but you shouldsubscribe from whatever email account you use mostduring the day or the email you want to receive

emergency notifications.From the unix prompt type pine pineT he system will indicate the welcome message for thefirst timeT ype c to compose a mail

Write majordomo@cs. iupui .ed u in the T o fieldLeave the Subject field blank T ype sub scr ibe cs230 below Message T extT ype control x to send the mailT ype q to quit

Page 14: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 14/17

1414

H ow to Use E macsH ow to Use E macs

pegasus{jsmith}1:emacs pegasus{jsmith}1:emacs f il ename f il ename

T here is a T utorial listing the major emacsT here is a T utorial listing the major emacscommands. I suggest you use the T utorial.commands. I suggest you use the T utorial.T o use the tutorial, type emacs at the prompt andT o use the tutorial, type emacs at the prompt andthen type <ctrl>h t. T his starts the tutorial.then type <ctrl>h t. T his starts the tutorial.Quick Access CardQuick Access Card ± ± LinuxLinux

Page 15: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 15/17

1515

H ow to Compile A ProgramH ow to Compile A Program

pegasus{jsmith}1: gcc pegasus{jsmith}1: gcc f irst1 f irst1 .c.c

C programs end in the ³.c´ extensionC programs end in the ³.c´ extensionT he executable file is calledT he executable file is called a. o ut a. o ut

pegasus{jsmith}1: gcc pegasus{jsmith}1: gcc f irst1.c f irst1.c

Page 16: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 16/17

1616

H ow to E xecute Y our ProgramH ow to E xecute Y our Program

pegasus{jsmith}1: pegasus{jsmith}1: a. o ut a. o ut T ype the name of the executable file at theT ype the name of the executable file at the

prompt to run your program prompt to run your program

Page 17: Lab Compiling Under Linux

8/6/2019 Lab Compiling Under Linux

http://slidepdf.com/reader/full/lab-compiling-under-linux 17/17

1717

Y our First C ProgramY our First C Program

# include <stdio.h># include <stdio.h>main(void)main(void){{

printf(³ H ello, CSCI 230! printf(³ H ello, CSCI 230!\ \n´);n´);

}}

T ry it!T ry it!