Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Introduction: Unix and C Software Project – Winter 2007 / 2008.

Similar presentations


Presentation on theme: "1 Introduction: Unix and C Software Project – Winter 2007 / 2008."— Presentation transcript:

1 1 Introduction: Unix and C Software Project – Winter 2007 / 2008

2 2 Administration

3 3 Teaching Assistant  T.A.: Michal Ozery-Flato E-mail: ozery@post.tau.ac.il Office Hours: by appointment Location: Schreiber 223  T.A. Website: http://www.cs.tau.ac.il/~ozery/courses/soft- project08/

4 4 The goals of the course  Learn C  Learn (a bit) Unix  Practice software development: Understanding software requirements Implementation Testing Deployment (i.e. installation, setting permission, verification) Working in small teams (submission is in pairs)

5 5 Course grade  Final grade is based on: Exam Assignments and final project:  “Black box” tests: automatic tests that run the program and check its output  “White box” tests: code review

6 6 Overview (for the rest of this lesson)  Introduction to Unix  Development environments for C Basic tools in UNIX Eclipse Visual Studio  Submission of assignments and project

7 7 Introduction to UNIX (and Linux…)

8 8 Operating Systems  An operating system (OS) is a software that: manages the resources of a computer: CPU, memory, devices provides programmers and users with an interface to access those resources. may support/provide: multi-tasking, multi-users, GUI, security, etc.  Interfaces:  Shell: a user interface based on a command- line interpreter. Users Application User Interface Program User Interface OS Kernal Hardware

9 9 The Unix OS  Unix: multi-user, multi-tasking OS; open source.  History: 1969 – Initial version by Thompson & Ritchie at AT&T Bell Labs. 70’s – Rewritten in C (enables portability). 80’s – System-V (AT&T) and BSD (Berkeley) versions. 90’s – Linux by Linus Torvalds. For basic introduction and commands - see course web-page (unix.doc)unix.doc

10 10 Basic commands in Unix shells CommandShort explanation ls -lprints the content of a directory pwdprints the name of the current directory cdchange directory mkdircreates a new directory cpcopies a file mvmoves a file/directory rmremoves (deletes) a file rmdirremoves an empty directory manhelp (manual) on a command

11 11 Additional Unix commands  cat – concatenate files and print to standard output cat file1 cat file1 file2 file3  less – file viewer (“less” is better than “more”)  which – locate a command  groups – prints the groups the user in (permission...)  grep – prints lines matching to a pattern grep –i “.*lib.*” foo.bar  find – search for a file in a directory find. –name “*.txt” –print find ~/ –name “*.o” -exec rm {} \;  clear – clears the terminal screen  finger – prints information about a user  who – shows who is logged in  whoami – identifies the current user

12 12 File and directory permissions in Unix  permissions = bits 2-10 (bit 1: “d”=directory, “-” = file) bit 1 = whether is a directory (d) or not (-) bits 2-4: owner permissions bits 5-7: group permissions bits 8-10: other permissions  rwx: r – read permission w – write permission x – execute (file)/ can cd (directory)  changing permissions: chmod chmod go+rx a.out chmod –R 755 mydir group permissions

13 13 Editing text files in Unix  Common text editors: pico - simple but very basic, similar to notepad vi, vim emacs, xemacs (GUI) - see course webpage for a simple tutorial  More info: man pico, man vi, man vim man emacs

14 14 Pipes and redirections to/from files  Pipe: prog1 | prog2 – the output of prog1 is redirected to the input of prog2 Example: ls –l | less  Output redirection to file prog > foo.out :may cause an error if foo.out exists prog >! foo.out :truncates foo.out if exists prog >> foo.out :may cause error if foo.out does NOT exist prog >>! foo.out :does not check whether foo.out exists  Input redirection (read from file) prog < foo.in

15 15 Comparing files (program tests)  prog ! my1.out : reading from 1.in and writing to 1.out  diff my1.out 1.out –compares files line by line  Ignoring all whitespaces: diff –w my1.out 1.out

16 16 Development environments for C

17 17 Printing "Hello World” in C #include int main(void) { printf(“Hello world!\n”); return 0; } Include the standard function declaration Call the printing function (declared in stdio.h)

18 18 C programming process Hello.c Edit Compile Link Hello.o Hello C Libraries Run Hello World! Source code (High-Level Language) Object file (Machine Language) ExecutableOutput

19 19 Basic tools in UNIX

20 20 Compiling and linking  Compiling and linking gcc hello.c –o hello  Only compiling (creating hello.o) gcc –c hello.c  Only linking gcc hello.o –o hello  Additional common flags to gcc: -g – allows debugging -l - linking with external libraries

21 21 Make and makefiles (in short)  makefile: a collection of rules to make targets  make: a utility that “executes” makefiles Makefiles will be covered later in the course. In the meanwhile, makefiles will be supplied all: hello clean: -rm hello.o hello hello: hello.o gcc -g hello.o -o hello hello.o: hello.c gcc -c -g hello.c rule target name dependencies command

22 22 gdb – the GNU debugger  Running gdb: gdb  Useful commands: help, quit, n, s, b /

23 23 Eclipse

24 24 Availability  Installed in the CS School LINUX lab (Linux) Including C/C++ projects  Working at home (Windows) Code requires porting to LINUX Relatively complicated installation  Cygwin: http://www.cygwin.com/http://www.cygwin.com/ Update PATH to contain c:\cygwin (or your alternative path)  CDT: http://www.eclipse.org/cdt/http://www.eclipse.org/cdt/ No support from course staff / helpdesk for installations

25 25 Create a new workspace /a/home/cc/students/cs/ozery/soft-proj08

26 26 Create a new project-1 (Linux lab)

27 27 Create a new project -2 (Linux Lab)

28 28 create a new project (windows)

29 29 Add source file

30 30 Add makefile (a file named “makefile”)

31 31 Build the project in each save. (LINUX Lab)

32 32 Project properties (windows)

33 33 Build the project

34 34 Running and Debugging (LINUX lab)  Right click on the executable file (with the bug icon ): Run As->Local C/C++ Application Debug As->Local C/C++ Application  Set debugger to “GDB Debugger”

35 35 Debugging under Windows+cygwin Console in a new window

36 36 Microsoft Visual Studio

37 37 Advantages / disadvantage, download info  Advantages: A common and friendly IDE for C/C++. Recommended for development under Windows A relatively simple installation, good support in the internet  Disadvantage: requires porting to Linux  Downloads: Visual Studio Express C++ (2005 edition) (see http://msdn2.microsoft.com/visualc/) Free download (2003 edition) at CS School “burning station” (see FAQ)  Available in the CS School Linux Lab – via nt-nlb application. Requires Windows account.

38 38 Creating a project (and a solution)

39 39 Adding new source files  Right click on project name: Add->New Item Write file name, including the.c suffix (e.g. file.c)

40 40 Build project

41 41 Compiling with debug information

42 42 Removing optimization

43 43 Linking with debug information

44 44 Debugging

45 45 Submission of assignments and project

46 46 Submission in pairs  The exercises and project are submitted in pairs If you do not have a partner – send me an e-mail (no single submissions) The exercise must be submitted in the home directories of both partners. The submitted directories of the two partners should be identical!

47 47 How to submit  Under ~/soft-proj08/ Strictly follow the provided file framework for each assignments / project Perform rebuild: make clean + make all Verify correct run: use given input/outfile + diff. Output should be exactly as specified! (do not add unnecessary friendly “printf” commands!) Before submission – give permission chmod -R 755 ~/soft-proj08  Manual submission - one for each pair printouts of code Should include: name, user-name, and id-number – of both partners! submitted to the checker’s mail-box (details will be given later)

48 48 Grading policy  If you do not follow the submission guidelines and your exercise cannot be automatically checked  your grade will be zero!  No appeals with submission/compilation/execution problems will be considered!

49 49 Appeals  Once your code is submitted – do not touch it! (we check time stamps)  Appeals must be submitted within 2 weeks after the grades publication.  To appeal : resubmit (to the checker’s mail-box) a detailed description of your appeal the original printout (with the checker’s comments).


Download ppt "1 Introduction: Unix and C Software Project – Winter 2007 / 2008."

Similar presentations


Ads by Google