T UTORIAL L ESSON Tools

24
TUTORIAL LESSON Tools Institute of Parallel and Distributed System (iPads) Shanghai Jiao Tong University Rong Chen rongchen @ sjtu.edu.cn

description

Institute of Parallel and Distributed System (iPads) Shanghai Jiao Tong University Rong Chen rongchen @ sjtu.edu.cn. T UTORIAL L ESSON Tools. OUTLINE. Pre-requisite SVN Toolchain. Pre-requisite SVN Toolchain. VERSION CONTROL. APT ( A dvanced P ackage T ools) - PowerPoint PPT Presentation

Transcript of T UTORIAL L ESSON Tools

Page 1: T UTORIAL  L ESSON Tools

TUTORIAL LESSONTools

Institute of Parallel and Distributed System (iPads)Shanghai Jiao Tong University

Rong [email protected]

Page 2: T UTORIAL  L ESSON Tools

OUTLINE

Parallel Processing Institute, Fudan University 2

Pre-requisiteSVNToolchain

Page 3: T UTORIAL  L ESSON Tools

Pre-requisiteSVN Toolchain

Parallel Processing Institute, Fudan University 3

Page 4: T UTORIAL  L ESSON Tools

VERSION CONTROL

APT (Advanced Package Tools) A management system for software

packages Package resource list for APT:

/etc/apt/sources.list

4

$ cat /etc/apt/source.list ... deb http://ftp.sjtu.edu.cn/debian/ squeeze main dbe-src http://ftp.sjtu.edu.cn/debian/ squeeze main type URI of source dist comp URI type: http, ftp, cdrom, file, ssh ...Institute of Parallel and Distributed System (iPads),

SJTU

Page 5: T UTORIAL  L ESSON Tools

VERSION CONTROL

APT (Advanced Package Tools) apt-get: command-line tool

update e.g. >apt-get update install e.g. >apt-get install htop remove e.g. >apt-get remove htop upgrade e.g. >apt-get upgrade htop

apt-cache: cache manipulator search e.g. >apt-cache search htop showpkg e.g. >apt-cache showpkg htop

5Institute of Parallel and Distributed System (iPads), SJTU

Page 6: T UTORIAL  L ESSON Tools

VERSION CONTROL

APT (Advanced Package Tools) example: install vim

>su root user >apt-get update update apt list >apt-cache search vim search in cache

>apt-get install vim install vim >man vim manual of vim

6

$ apt-cache search vim ... vim – Vi IMproved – enhanced vi editor vim-doc - Vi IMproved – HTML documentation ...Institute of Parallel and Distributed System (iPads),

SJTU

Page 7: T UTORIAL  L ESSON Tools

Pre-requisiteSVN Toolchain

Parallel Processing Institute, Fudan University 7

Page 8: T UTORIAL  L ESSON Tools

VERSION CONTROL

SVN (SubVersioN) Maintain current and historical

versions of files

Parallel Processing Institute, Fudan University 8

SVN1

SVN1

SVN1

22

2 1

2

1

2

11

22

2

Page 9: T UTORIAL  L ESSON Tools

VERSION CONTROL

SVN (SubVersioN) Install on Debian

Update e.g. >apt-get update Search e.g. >apt-cache search svn Install e.g. >apt-get install subversion

Uninstall e.g. >apt-get remove subversion

Parallel Processing Institute, Fudan University 9

Page 10: T UTORIAL  L ESSON Tools

VERSION CONTROL

SVN (SubVersioN) Client Command

checkoute.g. >svn co svn://10.132.143.1/truck truck --username=rong

update e.g. >svn update commit e.g. >svn ci a.c –message=“..” add file e.g. >svn add b.c

>svn ci b.c –message=“..” del file e.g. >svn del b.c

>svn ci b.c –message=“..”

Parallel Processing Institute, Fudan University 10

Page 11: T UTORIAL  L ESSON Tools

VERSION CONTROL

SVN (SubVersioN) Client Command

show status e.g. >svn status –q diff file e.g. >svn diff b.txt resolve conflict e.g. >vi a.c //manually remove conflict >svn resolved a.c

*svn resource link: http://subversion.tigris.org/ Parallel Processing Institute, Fudan University 11

Page 12: T UTORIAL  L ESSON Tools

Pre-requisiteSVNToolchain

C Language Compiling, Gcc Make

12

Page 13: T UTORIAL  L ESSON Tools

Why we choose C ? “ The limits of my language are the limits of my

world ” Tranctatus Logico-Philosophicus 5.6 1918

Our Requirements Realize Computer More Control Program Implement not Large but Practical Software Good Support in Multi-fields

Lisp

Script

Shell

Java

To C or Not to C

Parallel Processing Institute, Fudan University 13

Assembler

CBest Choice

Page 14: T UTORIAL  L ESSON Tools

HISTORY

Birth of C Language Thompson & Ritchie, 1969 ~ 1971 Based on B language

(BCPL, Basic Common Programming language) Rewrite Unix in C, 1973

ANSI (American National Standards Institute) C89 and C99

BOOK: The C Programming Language http://www.china-pub.com/computers/common/info.asp?id=14975Parallel Processing Institute, Fudan University 14

Page 15: T UTORIAL  L ESSON Tools

Pre-requisiteSVNToolchain

C Language Compiling, Gcc Make

15

Page 16: T UTORIAL  L ESSON Tools

GNU

What is GNU ? GNU is Not Unix, 1983

Richard M. Stallman (culture legend) Goal: absolutely FREE operating system The GNU Manifesto, 1985 Free Software Foundation (FSF)

Emacs, GCC, tar, … GPL, General Public License

Virus infectivity

Parallel Processing Institute, Fudan University 16

Page 17: T UTORIAL  L ESSON Tools

COMPILER

GNU Compiler Collection Preprocessor, Assembler, Linker,

Loader, … Support : C, C++, Java, Fortran, Ada,

Install on Debiane.g. >apt-get remove build-essential

Parallel Processing Institute, Fudan University 17

Page 18: T UTORIAL  L ESSON Tools

COMPILING

Parallel Processing Institute, Fudan University 18

Source Codes

[*.c, *.h]

C Program Preprocessor

Source Codes[*.c]

C ProgramCompiler

Assembly Codes[*.s]

AssemblerLinker/Loader

GNU Compiler Collection

E

co

S

Binary Codes[*.out]

Binary Codes[*.o]

Page 19: T UTORIAL  L ESSON Tools

COMPILING

C Files Compilation Example C Files: test.h test.c e.g.

>gcc -E test.c > test-pp.c (test-pp.c)>gcc -S test.c (test.s)>gcc -c test.c (test.o)>gcc -o test test.c (test)

Parallel Processing Institute, Fudan University 19

Page 20: T UTORIAL  L ESSON Tools

Pre-requisiteSVNToolchain

C Language Compiling, Gcc Make

20

Page 21: T UTORIAL  L ESSON Tools

MAKE

Make Automatically building executable

programs and libraries from source codeaccording to files called “Makefile”

GNU make

BOOK: ”Managing Projects with GNU Make”

http://www.china-pub.com/computers/common/info.asp?id=25525

Parallel Processing Institute, Fudan University 21

Page 22: T UTORIAL  L ESSON Tools

MAKEFILE

“Makefile” Specify how to derive the target

program from each of its dependencies

Context The relationship among source files The command used to compile source files

Tools for auto building Makefile makedepend, Imake, autoconf, automake

Parallel Processing Institute, Fudan University 22

Tips: disadvantage of make tab and whitespace are different

Page 23: T UTORIAL  L ESSON Tools

EXAMPLE

Parallel Processing Institute, Fudan University 23

>lsgen_log.c gen_sort.c>makegcc –Wall -I. -O3 gen_log.c -o gen_loggcc –Wall -I. -O3 gen_sort.c -o gen_sort>make cleanrm gen_log gen_sort>make gen_sortgcc –Wall -I. -O3 gen_sort.c -o gen_sort

CC := gccOPT := -O3CFLAGS := -Wall -I. $(OPT)

BINS := gen_log gen_sort

all: $(BINS)

%.o: %.c$(CC) -c -o $@ $^ $(CFLAGS)

clean:rm $(BINS) Makefile

Page 24: T UTORIAL  L ESSON Tools

Parallel Processing Institute, Fudan University 24

Thanks