Download presentation
Presentation is loading. Please wait.
1
1 Introduction: Unix Software Project – Autumn 2008/2009
2
2 Administration
3
3 Teaching Assistant Michal Ozery-Flato Website: http://www.cs.tau.ac.il/~ozery/ courses/soft-project09/ E-mail: {ozery}@post.tau.ac.il Office Hours: by appointment
4
4 The goals of the course Learning C Learning (a bit) Unix Practicing software development: Understanding software requirements Implementation Testing Deployment (i.e. installation, setting permissions, verification) Working in small teams (submission is in pairs)
5
5 Course grade Exam (30%) Assignments and final project (70%): “Black box” tests: automatic tests that run the program and check its output 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. Case sensitive (commands, filenames...) 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)/ enter (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 vi, vim - two modes: command / write 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 Working from home... Putty - shell window Winscp - copying files Links: http://www.cs.tau.ac.il/faq/ http://www.cs.tau.ac.il/faq/index.php/%D7%92%D7%99%D 7%A9%D7%94_%D7%9C%D7%A9%D7%A8%D7%AA%D7 %99%D7%9D http://www.cs.tau.ac.il/faq/index.php/%D7%92%D7%99%D 7%A9%D7%94_%D7%9C%D7%A9%D7%A8%D7%AA%D7 %99%D7%9D
17
17 Development environments for C
18
18 Printing "Hello World” in C #include int main(void) { printf(“Hello world!\n”); return 0; } Include the standard function declarations (prototypes) print to standard output (declared in stdio.h)
19
19 C programming process Hello.c Edit Compile Link Hello.o Hello C Libraries (machine code) Run Hello World! Source code (High-level language) Object file (Machine code) ExecutableOutput
20
20 Basic tools in UNIX
21
21 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: -ansi -pedantic-errors - verifies that the code is ANSI C compliant -g – allows debugging -l - linking with external librarie -lm - if a math function is called (e.g. pow(x))
22
22 Make and makefiles (in short) makefile: a file containing a collection of rules. Used for building applications The default name of a filename: "makefile" make: a utility for “executing” makefiles Makefiles will be covered later in the course. Till then, 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 -ansi -pedantic-errors -g -c hello.c rule target name dependencies command makefile
23
23 How to use makefiles 1. Copy the makefile into the appropriate directory (e.g. the directory containing the source files) 2. In a shell window (e.g. putty) change to the directory containing the makefile 3. Use the commands: "make clean"+ "make all" to build the executable
24
24 gdb – the GNU debugger Running gdb: gdb Useful commands: help, quit, n, s, b /
25
25 Eclipse
26
26 Availability Installed in the CS School LINUX lab (Linux) Including C/C++ projects Working at home (Windows) - not recommended 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
27
27 Create a new workspace /a/home/cc/students/cs/ozery/soft-proj09
28
28 Create a new project-1 (Linux lab)
29
29 Create a new project -2 (Linux Lab)
30
30 create a new project (windows)
31
31 Add source file
32
32 Add makefile (a file named “makefile”)
33
33 Build the project in each save. (LINUX Lab)
34
34 Project properties (windows)
35
35 Build the project
36
36 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”
37
37 Debugging under Windows+cygwin Console in a new window
38
38 Microsoft Visual Studio
39
39 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 Free download: Visual Studio Express C++ (2008 edition) see http://msdn2.microsoft.com/visualc/http://msdn2.microsoft.com/visualc/
40
40 Creating a project (and a solution)
41
41 Adding new source files Right click on project name: Add->New Item Write file name, including the.c suffix (e.g. file.c)
42
42 Build project
43
43 Compiling with debug information
44
44 Removing optimization
45
45 Linking with debug information
46
46 Debugging
47
47 Submission of assignments and project
48
48 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!
49
49 How to submit Under ~/soft-proj09/ 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 755 ~ chmod -R 755 ~/soft-proj09 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)
50
50 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!
51
51 Appeals Once your code is submitted – do not touch it! (we check time stamps) Appeals must be submitted within one week after grades publication. To appeal : resubmit to the checker’s mail-box (Yehudit Hasson): 1. The original printout (with the checker’s comments). 2. A detailed description of your appeal
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.