You are on page 1of 2

Software engineering & System programming :

Software progamming: provide services to end users


System programming :provide services to other softwares

Linux OS && C C++

static and dynamic libraries :

dependencies management using Make file


program analysis(debug and compilation))GNU debugger !!

vectorial processing !

Modern CPU architecture!

Energy managment !

Software prortability!

______________________________________________________________________

Lecture 1: Structuring c c++ program !

Example1: C code of factorial function

int factorial (int n ){


int P=1;
for(int i=1 ; i<= n; i++)
{
p = p*i;
}
return P;
}

int main(){
return factorial(n);
}

linking and compilation operation:

gcc -> compiler only! (compilation)

ld -> layer linker (linking)


ld factorial - o

Note : inorder to call the function factorial

We have to use the prototype of the function !


fact.c file
fact.h file !

so we just add int factorial(int); and include #include<fact.h>


The header file is used for the compilation phase !!!
if we miss the header file we get compilation erorrs not the linking error !

Make the difference between compilation error and linking error !

to link the printf function we use #include std lib.so or lib.a

Structuring the source code !


Structuring binaries !

Specify to the user to use a specified libary

-lm <>clibm

ask the linker to link with a particular library!


libpthreads so or a

-lpthreads

You might also like