What Is Meant by Compilation?: High Level Lo W Level Compiler
What Is Meant by Compilation?: High Level Lo W Level Compiler
The process of translating source code written in high level to low level machine code is called as
Compilation. The compilation is done by a special software known as compiler. The compiler checks
source code for any syntactical or structural errors and generates object code with extension .obj (in
Windows) or ,o (in Linux) if source code is error free.
The C compilation
The entire C compilation is broken to four stages.
1. Pre-processing
2. Compilation
3. Assembling
4. Linking
Write the c program below
#include <stdio.h>
int main()
{
printf("Learn at Codeforwin!");
return 0;
}
To compile the above program open command prompt and hit below command.
The -save-temps option will preserve and save all temporary files created during the C compilation.
It will generate four files in the same directory namely.
- compilation.i (Generated by pre-processor)
- compilation.s (Generated by compiler)
- compilation.o (Generated by assembler)
- compilation (On Linux Generated by linker) or (compilation.exe On Windows)
- Une librairie dynamique (.dll et .so) n'est pas recopiée dans l'exécutable final (ce qui
signifie que le programme est plus petit et bénéficiera des mises à jour de ladite librairie).
En contrepartie, la librairie doit être présente sur le système sur lequel tourne le
programme.
- Une librairie statique (.a) est recopiée dans l'exécutable final ce qui fait que celui-ci est
complètement indépendant des librairies installées du le système sur lequel il sera
recopié. En contrepartie, l'exécutable est plus gros, il ne bénéficie pas des mises à jour de
cette librairie etc...
Le linker vérifie en particulier que chaque fonction appelée dans le programme n'est pas
seulement déclarée (ceci est fait lors de la compilation) mais aussi implémentée (chose
qu'il n'avait pas vérifié à ce stade). Il vérifie aussi qu'une fonction n'est pas implémentée
dans plusieurs fichiers .o.
Cette phase, appelée aussi édition de lien, constitue la phase finale pour obtenir un
exécutable (noté .exe sous windows, en général pas d'extension sous linux).
LIB is a static library where functions and procedures can be placed and called as the application is
being compiled.
A DLL or Dynamic Link Library does the same function but is dynamic in a sense that the application
can call these libraries during run-time and not during the compilation.
For starters, you would have a single file that is significantly bigger as it contains all of the code
while you would have multiple smaller files when using DLL. Compiling your functions and
procedures would also allow you more reusability as once you are happy with the functions on the
DLL because you can keep it as is with each version of the application and not have to mess with it.
You can also use the same DLL if you want to create another application that uses the same
functions and procedures. You can directly link to the DLL rather than copy the code from the
source as you would need to do with LIB.
A problem with DLL is when you change the content of the DLL. This can lead to versioning
problems where an application uses the incorrect version of the DLL causing problems. You need to
keep track of your DLLs in order to avoid these problems. You would not have this problem with LIB
as you would only get one large file.
When developing the software and choosing DLL, you would still have a LIB file in your project. But
unlike when using LIB, this file does not contain the code of the functions and procedures but only
stubs that the program needs to call the procedures from the DLL’s.
Summary:
1. A DLL is a library that contains functions that can be called by applications at run-time while LIB is
a static library whose code needs to be called during the compilation
2. Using LIB would result in a single file that is considerable bigger while you end up with multiple
smaller files with DLL’s
3. DLL’s are more reusable than LIBs when writing new versions or totally new applications
4. DLL files can be used by other applications while LIB files cannot
5. DLL’s are prone to versioning problems while LIB is not
6.You would still have a LIB file when developing software with DLLs but it only contains stubs