Use makefile

This tip submitted by cjediknight on 2005-08-05 05:19:01. It has been viewed 56596 times.
Rating of 5.6 with 180 votes

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

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

then at command run run make

More tips

Help your fellow programmers! Add a tip!