Lecture01
Lecture01
Compilers Design
1 - Introduction
Reference
Introduction to Compiler Design, Mogensen, Torben Ægidius
A preview of this book is available at Google-Books:
https://books.google.com.eg/books?id=KvDustn1eikC&printsec=frontcover&sourc
e=gbs_ge_summary_r&cad=0#v=onepage&q&f=false
1.8 Linkers
A linker collects different object files into an executable file. A linker also connects
an object program to the code for standard library functions.
3
Example
Consider the following C++ program:
Saved as "test.cpp"
#include <stdio.h>
int main()
{
int x = 2;
int y = 3;
int z = x + y;
printf("z = %d\n",z);
double a = 2.5;
return 0;
}
When you make (build) the program (run it), the following things happens:
• The source file "test.cpp" is compiled to an object file "test.obj"
• The linker collects the object file "test.obj" with the code in the library file "stdio.h",
the part of "stdio.h" that contains "printf" is compiled and added to "test.obj"