CS 261 Recitation 1 - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

CS 261 Recitation 1

Description:

Linking the code uses the information from the object code to build executable. ... Codeblocks is a free C IDE built to meet the most demanding needs of its users. ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 21
Provided by: duc56
Category:
Tags: code | free | php | recitation

less

Transcript and Presenter's Notes

Title: CS 261 Recitation 1


1
CS 261 Recitation 1
Oregon State University School of Electrical
Engineering and Computer Science
  • Fall 2009

2
Outline
  • Using Secure Shell Clients
  • Basic commands
  • Text Editors
  • The GCC
  • Some Examples
  • C IDE in Windows

3
Using Secure Shell Clients
  • Open Secure Shell Client (for Windows PC)
  • Open Terminal type ltusernamegt_at_lthost namegt
    (for Mac)

4
Using Secure Shell Clients
  • List of available servers
  • flip.engr.oregonstate.edu
  • flop.engr.oregonstate.edu off-campus
  • shell.onid.oregonstate.edu
  • and more (see http//eecs.oregonstate.edu/it/)

5
Using Secure Shell Clients
Transferring your files to UNIX account
6
Using Secure Shell Clients
  • Other Secure shell clients available
  • Remote connect PuTTY
  • http//www.chiark.greenend.org.uk/sgtatham/putty
    /
  • File Manager WinSCP
  • http//winscp.net/eng/index.php

7
Basic commands
  • pwd
  • Present working directory
  • ls/dir
  • list files and directories in current directory
  • cd
  • Change directory
  • cd ..
  • move to parent directory
  • mkdir
  • make new directory
  • cp
  • copy ltsrcFileNamegt ltdesFileNamegt
  • rm
  • remove file
  • rmdir
  • remove folder
  • cat
  • show file content
  • exit

8
Text Editors
  • Emacs
  • To start emacs ltfilenamegt
  • Common commands
  • Ctrl X Ctrl S Save
  • Ctrl X Ctrl C Exit
  • More information http//lowfatlinux.com/linux-edi
    tor-emacs.html
  • Vim
  • To start vim ltfilenamegt
  • 3 modes for text editing
  • Insert (i)
  • Replace (r / R)
  • Browse (Esc)
  • To save - w
  • To quit - q
  • More information http//vimdoc.sourceforge.net/h
    tmldoc/usr_toc.html

9
Task 1
  • Use any Secure Shell Client to connect
    flip.engr.oregonstate.edu
  • Create a folder named CS261
  • Change working directory to CS261
  • Create a folder named Rec1
  • Create a folder named Temp
  • Remove folder Temp
  • Change working directory to Rec1
  • Use emacs or vim, create and file named info.txt
    and input your name.
  • Use cat to show content of info.txt
  • Copy info.txt to the CS261 folder
  • Delete both info.txt files.
  • (check your work with file transfer tool)

10
The GCC
  • The GNU Compiler Collection (usually shortened to
    GCC) is a command line compiler system produced
    by the GNU Project, supporting various
    programming languages (includes C, C).
  • Compiling with GCC
  • gcc ltlist of optionsgt sourcefile.c
  • e.g. gcc -Wall ansi -o test test.c
  • Output
  • Compiling the code converts it into object files
    (.o)
  • Linking the code uses the information from the
    object code to build executable.

11
Using the GCC compiler (cont.)
  • Common options
  • -Wall Show all warnings
  • -ansi Using standardized version of ANSI C
  • -o ltfilenamegt Name the output file
  • -c Compile but dont link

12
Using the GCC compiler (cont.)
  • Compile multiple files
  • To stop the process till compilation step
  • gcc c code1.c code2.c code3.c
  • To link the individual .o files to generate the
    executable
  • gcc o executor code1.o code2.o code3.o
  • The same can be done in a single step
  • gcc o executor code1.c code2.c code3.c

13
Examples
  • Example 1 Hello World
  • Example 2 Hello World with Header file
  • Example 3 Swap

14
C IDE in Windows, Mac OS x
  • Codeblocks is a free C IDE built to meet the
    most demanding needs of its users. It is designed
    to be very extensible and fully configurable.
  • To download, go to http//www.codeblocks.org/down
    loads/5

15
Programming C using CodeBlocks
  • Open CodeBlocks
  • File gt New gt Project gt Empty Project gt Go

16
Programming C using CodeBlocks (Cont.)
  • Enter Project Title, Folder, Project
    filename, and Resulting fileName

17
Programming C using CodeBlocks (Cont.)
  • Select GNU GCC Compiler
  • Check the two checkboxes if you want to create
    debug and release configuration.

18
Programming C using CodeBlocks (Cont.)
  • Add source file to this project File gt New gt
    File gt C/C Source gt Choose C as the programming
    language. After that, enter file name with full
    path, remember to turn on Add file to active
    project
  • The procedure is similar when adding a header
    file.

19
Programming C using CodeBlocks (Cont.)
  • To build the project, press Ctrl F9
  • To run the project, press Ctrl F10

20
NOTE
  • You can use any program to develop and test your
    C application before submitting. However, UNIX is
    the environment in which the program will be
    graded. So make sure your program will compile
    and run without errors or warnings when using GCC.
Write a Comment
User Comments (0)
About PowerShow.com