Download presentation
Presentation is loading. Please wait.
1
Environment & tools Assistant Anssi Jääskeläinen Visiting hours: Tuesdays 11-12 Room: 6606 jaaskela@lut.fi
2
Arrangements Six programming assignments One home examination Every task is individual You must attend to minimum of 5 out of 6 practice sessions –Todays session is not count –Try to participate to the same practice group every time One or two persons are selected to present and EXPLAIN their code and demonstrate the application –Conversations –Modifications –Etc.
3
Requirements for assignments Comment your code –Even a total ignorant to C-code has to understand what is happening and where Use makefile –Make has to be able to compile your program in this class Add your name and student ID to the begin of every source code file Write a readme file that contains: –Instruction how to run program –Parameters –Other issues that may affect the program All assignments must be returned in order to pass the course Your program has to compile & work in this class room
4
Delay table -1 point1 - 59 minutes -Accepted but 0 points for this assignment More -2 points1 – 8 hours Penalty in pointsDelay time
5
Emacs Some basic commands –emacs ”filename” starts emacs and opens file –C-x C-s = save file –C-x C-w = save file to alternative name –C-x C-f = open/create file –C-x C-c = close emacs –C-x k = kill current buffer –C-x o = select another window –C-x 1 = get rid of all windows exept the selected one –C-x C-b = list current buffers –C-x b number = go to buffer number –F10 enter menu Arrow keys page up –List of commands http://lpn.rnbhq.org/tools/xemacs/emacs_ref.htmlhttp://lpn.rnbhq.org/tools/xemacs/emacs_ref.html Syntax highlighting –F10 – options – Syntax highlighting –Possible to automatically turn this on
6
Task Open your favourite editor and write a simple helloworld application #include //what is this int main(void) { printf("Hello world!\n"); //remember to comment your code return 0; } Save it
7
Tar / Gzip tar -cvvf foo.tar hello.c (Tar contents of folder foo to foo.tar) tar –xvvf foo.tar (extract foo.tar) tar –xvvzf foo.tar.gz (extract gzipped foo.tar.gz) gzip archive.tar gunzip arhive.tar.gz TASK –Back you hello files to tar.gz file
8
GCC Gnu Compiler Collection http://gcc.gnu.org/ Options –g level = include debugging information Always use –g option –You may think your program is correct but there is no sense in pushing your luck.. –v = verbose mode –o = specify output file, default is a.out –Wall = All warning messages –http://www.oreillynet.com/linux/cmd/cmd.csp?path=g/gcchttp://www.oreillynet.com/linux/cmd/cmd.csp?path=g/gcc TASK –Compile your helloworld with gcc –v –o helloword yourfilename.c –Run with./helloworld –Play with different compilation options (use man pages to find those)
9
Make Makefile tells make what to do –How to compile and link a program –How to clean up –man make
10
Makefile http://www.gnu.org/software/make/manual/http://www.gnu.org/software/make/manual/ http://www.eng.hawaii.edu/Tutor/Make/ http://www.network-theory.co.uk/docs/gccintro/gccintro_16.html target: source file(s) command “gcc …” If only one target is specified in makefile, it will be automatically used just by running make Task –Write a makefile for your helloworld –Compile your program with make –Add makefile and compiled binaries to your tar.gz file
11
GDB the Gnu project debugger Allows you to see what is going on inside another program Can do four main kinds of things –Start your program, specify parameters –Make the program stop on specified conditions –Examine what has happened –Change things in the program http://sourceware.org/gdb/documentation/ This is not mandatory program to pass this course –But it may help you on your way
12
Using GDB GDB can be used alone or under Emacs –Start under emacs with F10 tools debugger (or with mouse) http://sourceware.org/gdb/current/onlinedo cs/gdb_toc.html#SEC_Contentshttp://sourceware.org/gdb/current/onlinedo cs/gdb_toc.html#SEC_Contents Remember to use –g option when compiling
13
Continue Commands –Ctrl –c ends running program –List = lists loaded code –break n = sets breakpoint to line n –break try = sets break point to place where function try is called breaks can be conditional –break x if ownvariable>5 –step = runs next line of code –next = runs next line of code but does not enter functions –quit = quits debugging –list x = lists code around point x –where = shows current position in debugging
14
GDB task Write an error or errors to your helloworld –endless loop –Unaccessible condition –etc. –Anything is fine as long as it passes compiler Compile your code Debug it
15
Assignment 1 Simple UDP quiz Deadline 7.9.2008 – 23.59 –Delay will lead to penalty client-server program, which implements a simple quiz for the users. One user creates a question and correct answer, others try to answer this. –First client that enters will get the question turn –Entered questions are submitted to all clients currently active (late arrivals should receive it also) –Question stays active until correct answer is given –Server gives question turn to other client –More specific instructions can be found from the assignment page
16
Other things Help desk might be available after this week Assistant can try to answer questions but result might not be that good.. Helpfull sources –Beej's Guide to Network Programming –google –BOOKS TCP/IP illustrated TCP/IP Sockets in C: Practical Guide for Programmers Linux Socket Programming by Example
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.