Thursday, August 28, 2014

compilation and linking

Compilation occurs in two phases:
  • Compilation: the process of turning the C source into low-level binary or "object" code.
  • Linking: the process of combining multiple object files into a single executable, adjusting references so accessing variables or functions in other files works correctly.

root@selvakumar-Lenovo-B460e:/C_pgms/static-func# cat one.c two.c 
void fun()
{
printf("\nfun\n");
}
#include<stdio.h>
int main()
{
fun();
return 0;
}
root@selvakumar-Lenovo-B460e:/C_pgms/static-func# gcc -c one.c two.c 
one.c: In function ‘fun’:
one.c:3:2: warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
root@selvakumar-Lenovo-B460e:/C_pgms/static-func# gcc -o output one.o two.o
root@selvakumar-Lenovo-B460e:/C_pgms/static-func# ./output 

fun
root@selvakumar-Lenovo-B460e:/C_pgms/static-func# 

No comments:

Post a Comment