Beruflich Dokumente
Kultur Dokumente
Algorithms and
programming techniques
Monday
16:30 - 17:50 (1026)
Tuesday
13:30 - 14:50 (1028)
Friday
12:00 - 13:20 (1027)
Consultations
Room 2301, Monday 13:30-14:50
Appointment by email cristian.uscatu@ie.ase.ro
Prerequisites
Basic computer knowledge and abilities
Programing basics (first semester)
Basic Visual Studio skills
Visual Studio
Other books
I. Gh. Roca, B. Ghilic-Micu, C. Cocianu, M. Stoica, C. Uscatu, M. Mircea,
Programarea calculatoarelor. Algoritmi n programare, Editura ASE Bucureti, 2007
C. Uscatu, M. Popa, L. Pocatilu (Btgan), C. Silvestru, Programarea
calculatoarelor. Aplicaii, Editura ASE Bucureti 2012
Thomas H. Cormen, Charles E. Leiserson, Ronald R. Rivest, Introducere n
algoritmi, Computer Libris Agora, 2000
Evaluation
Seminar:
40%
Examination: 50%
Ex officio: 10%
Miscellaneous
Attendance, missed classes, individual study, rules, collaboration
Libraries
Purpose
Code reuse for multiple applications
Distribution to other users
Types
Source code, binary (object) code
Static, dynamic
Libraries
Work options
Command line
cl.exe
- compiler
lib.exe
- library manger
link.exe - link editor
In IDE (Visual Studio)
Same solution (with multiple projects)
Separate solutions
Static libraries
File extension
Windows:
Linux:
.lib
.a
Advantages
Single executable file
Only called functions are extracted from the library and inserted
in the program
Drawbacks
Larger executable file
Each executable includes a separate copy of the same functions
Static libraries
Compile
Object code
(.obj)
Compile
Object code
(.obj)
Library
manager
Object code
library
(.lib)
Link editor
Object code
library
(.lib)
Executable
file
(.exe)
Static libraries
#include
#include
#include
//alocare
<stdio.h>
<malloc.h>
"matrice.h"
dinamica matrice
Source
files
test.cpp
a=citire_matrice(&m);
//afisare matrice patrata
afisare_matrice(a,m);
// I - adresa matrice, dimensiune
Static libraries
Command line
Create a new folder and save the required files
Run vcvars32.bat, found in Visual Studios folder bin
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
cl -c matrice.cpp
matrice.obj
cl test.cpp matrice.lib
test.exe
Static libraries
Static libraries
Static libraries
Dynamic libraries
File extension
Windows:
Linux:
.dll
.so
Advantages
Smaller executable
The library is shared by several applications
Drawbacks
Several files (main executable + dynamic libraries)
Additional processing time
Library must be on the search path or current folder
Dynamic libraries
Create
dynamic
library
Use library
Launch
application
with
dynamic
library
Source
code
(.c, .cpp, .h)
Source
code
(.c, .cpp, .h)
Compile
Compile
Object file
(.obj)
Import table
(.lib)
Link editor
Object file
(.obj)
Link editor
Dynamic
library
(.dll)
Executable
file
(.exe)
Dynamic
library
(.dll)
Object code
library
Executable
file
(.exe)
Dynamic libraries
Differences
Function prototypes must include (only the header file .h)
__declspec(dllexport)
path)
Dynamic libraries
Command line
Create a new folder for the project, include the 3 files
Run vcvars32.bat, from bin folder of Visual Studio
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
cl matrice.cpp /LD
matrice.dll, matrice.lib
cl test.cpp matrice.lib
test.exe
Dynamic libraries
Dynamic libraries
Dynamic libraries
Libraries
HOMEWORK!
Create and test a library with functions for processing
Dynamic library
Work in command line
Work in IDE (separate solution)
Dynamic libraries
HOMEWORK!
Size comparison:
Static (.lib)
matrice.h
Dynamic (.dll)
L.C.
IDE
L.C.
IDE
matrice.lib
matrice.dll
test.exe
Spor la nvat!