@ Build Process
main.c
-- Preprocess --> main.i
-- Compile --> main.s
-- Assemble --> main.o
-- Link --> a.out
To check this,
# gcc -v --save-temps main.c // main.i, main.s, main.o created
@ Seperated Compilation
----------------------------------------
"main.c"
#include <stdio.h>
void main()
{
hi();
}
"hi.c"
void hi()
{
printf("Hi\n");
}
----------------------------------------
# gcc main.c // link error !
# gcc hi.c // link error !
Like this,
# gcc -c main.c // main.o created
@ Add Including Directory
# gcc main.c -I/usr/inc
main.c
-- Preprocess --> main.i
-- Compile --> main.s
-- Assemble --> main.o
-- Link --> a.out
To check this,
# gcc -v --save-temps main.c // main.i, main.s, main.o created
@ Seperated Compilation
----------------------------------------
"main.c"
#include <stdio.h>
void main()
{
hi();
}
"hi.c"
void hi()
{
printf("Hi\n");
}
----------------------------------------
# gcc main.c // link error !
# gcc hi.c // link error !
Like this,
# gcc -c main.c // main.o created
# gcc -c hi.c // hi.o created
# gcc -o program main.o hi.o // execute linking, executable binary named 'program' created
@ Add Including Directory
# gcc main.c -I/usr/inc
No comments:
Post a Comment