Cursul #7
Dezvoltarea programelor
1
There are only two kinds of programming languages: those people always bitch about and those nobody uses.
Bjarne Stroustrup
2
Suport de curs
3
Evoluția programării
4
Conexiune dezvoltator - utilizator
5
Fișier cod sursă
Fișier cod sursă
biblio-tecă
Fișier obiect
Fișier obiect
Fișier executabil
Pachet software
Fișier de configurare
Fișier de date
compilare
compilare
linking
Dezvoltator
Utilizator
Pachete software
6
student@host:~$ dpkg -L tcpdump
[...]
/usr/share/man/man8/tcpdump.8.gz # pagina de manual
[...]
/usr/sbin/tcpdump # executabilul din pachet
Operațiile utilizatorului cu aplicațiile
7
Fișiere cod sursă
8
Editoare
În mod text:
9
În interfață grafică:
Caracteristici editoare
10
Medii integrate de dezvoltare (IDE)
11
Compilare
12
Etapele compilării
13
Etapele compilării
14
Interpretare
15
Compilare vs interpretare
Compilare
16
Interpretare
Limbaje hibride
17
Biblioteci și framework-uri
18
De ce programare în C?
19
De ce nu programare în limbajul C?
20
Dezvoltarea aplicațiilor în C
21
Compilare de program simplu în C
student@host$ ls -F
hello-world.c
student@host$ gcc hello-world.c
student@host$ ls -F
a.out* hello-world.c
student@host$ rm a.out
student@host$ ls -F
hello-world.c
student@host$ gcc -Wall hello-world.c -o hello-world
student@host$ ls -F
hello-world* hello-world.c
student@host$ ./hello-world
Hello, World!
22
Compilare și linking de program simplu în C
student@host$ ls -F
hello-world.c
student@host$ gcc -Wall -c hello-world.c
student@host$ ls -F
hello-world.c hello-world.o
student@host$ gcc hello-world.o -o hello-world
student@host$ ls -F
hello-world* hello-world.c hello-world.o
student@host$ ./hello-world
Hello, World!
23
Modularizare și modul
24
Compilare și linking din surse multiple
user@host$ ls -F
debug.h http_reply_once.c sock_util.c sock_util.h util.h
user@host$ gcc -Wall -c sock_util.c
user@host$ gcc -Wall -c http_reply_once.c
user@host$ ls -F
debug.h http_reply_once.o sock_util.h util.h
http_reply_once.c sock_util.c sock_util.o
user@host$ gcc http_reply_once.o sock_util.o -o http_reply_once
user@host$ ls -F
debug.h http_reply_once.c sock_util.c sock_util.o
http_reply_once* http_reply_once.o sock_util.h util.h
25
Procesul de build
26
Sisteme de build
27
Automatizarea procesului de build - make
28
Regula: dependinte
<tab> comanda
Exemplu fișier Makefile
29
build: utils.o hello.o help.o
gcc utils.o help.o hello.o -o hello
all:
gcc simple_hello.c -o simple
utils.o: utils.c
gcc –c utils.o
hello.o: hello.c
gcc –c hello.c
help.o: help.c
gcc –c help.c
clean:
rm –f *.o hello
Folosire simplă make
30
all: hello-world
hello-world: hello-world.c
gcc –Wall hello-world.c –o hello-world
clean:
rm –f hello-world hello-world.o
student@host$ ls -F
hello-world.c
student@host$ make
gcc -Wall hello-world.c -o hello-world
student@host$ ls -F
hello-world* hello-world.c
Folosire elegantă a Make pentru surse multiple
31
.PHONY: all clean
All: http_reply_once
http_reply_once: http_reply_once.o sock_util.o
gcc http_reply_once.o sock_util.o -o http_reply_once
http_reply_once.o: http_reply_once.c util.h debug.h sock_util.h
gcc -Wall -c http_reply_once.c
sock_util.o: sock_util.c util.h debug.h sock util.h
gcc -Wall -c sock util.c
clean:
rm -f http_reply_once http_reply_once.o sock_util.o
rm -f *
student@host$ ls -F
Makefile debug.h http_reply_once.c sock_util.c sock_util.h util.h
student@host$ make
gcc -Wall -c http_reply_once.c
gcc -Wall -c sock_util.c
gcc http_reply_once.o sock_util.o -o http_reply_once
student@host$ ls -F
Makefile http_reply_once* http_reply_once.o sock_util.h util.h
debug.h http_reply_once.c sock_util.c sock_util.o
Depanarea programelor
32
Sisteme de management și versionare
33
Licențe pentru programe
34
Resurse utile
35
Compilers: Principles, Techniques and Tools
36
Guido van Rossum
37
38
Valgrind
39
Cuvinte cheie
40