Use makefile

This tip submitted by cjediknight on 2005-08-05 05:19:01. It has been viewed 45658 times.
Rating of 6.1 with 137 votes




When writting a large program, always use a multi-source file compilation.
do this by creating a make file.

example:
if you have main.c as main program, file1.c and file2.c as sub program.
link it to main by creating makefile like this.

$vi makefile
main: main.o file1.o file2.o
gcc -o main.o file1.h
file1.o: file1.h
gcc -c file1.c
file2.o: file2.h
gcc -c file2.c
esc+wq+enter

then at command run run make
$make



More tips

Help your fellow programmers! Add a tip!