Compilation Steps For a Hello World program :
#include<stdio.h>
int main()
{
printf(“Hello World \n”);
return 0;
}
Step One :The C preprocessor implements the macro language used to transform C,C++, and Objective-C programs before they are compiled.
aregee@linuxstation src_projects$ cpp hello.c > hello.i
aregee@linuxstation src_projects$ ls
hello.i
hello.c
aregee@linuxstation src_projects$
Step Two : In this stage the hello.i is compiled to assembly language. -S option with gcc creates a hello.s file
aregee@linuxstation src_projects$ gcc -S hello.i
aregee@linuxstation src_projects$ ls
bashme Depriciated Gdata_Module hello.i m_c resultworks
Ddev file_rem.py hello.c hello.s Pong_game
Step Three : The Assembler can be invoked with the following command and what assembler does is to convert the hello.s to ELF(executable linked format) hello.o
aregee@linuxstation src_projects$ as hello.s -o hello.o
aregee@linuxstation src_projects$ ls
bashme Depriciated Gdata_Module hello.i hello.s Pong_game
Ddev file_rem.py hello.c hello.o m_c resultworks
aregee@linuxstation src_projects$+++++reading hello.o++++++++++
$ readelf -a hello.o
Step Four : The Linker links all the resources required for the execution,thus it links /loads the .so libraries dynamically during the run time…
To link the hello.o file to the dependent libraries,
aregee@linuxstation src_projects$ gcc hello.o
aregee@linuxstation src_projects$ ls
a.out Ddev file_rem.py hello.c hello.o m_c resultworks
bashme Depriciated Gdata_Module hello.i hello.s Pong_game
aregee@linuxstation src_projects$aregee@linuxstation src_projects$ ./a.out
Hello World
Finding Dynamically linked libraries :
aregee@linuxstation src_projects$ ldd a.out
linux-vdso.so.1 => (0x00007fffaf962000)
libc.so.6 => /lib64/libc.so.6 (0x0000003d0bc00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003d0b400000)
Sir
neither document nor assignment for project-03,is not visible in my account.
please sir can you add this document.
raj
Meet Kamal Maam.