13 May 2010

using make to build c files

Actually, It is the first time I use make (as I usually use ant instead)

read about make here

So, let's start our first make example :
(Note: you need to have a Linux machine)
1- write the following c program (save it as program1.c)


int main(void){
printf("Hello World with make\n");
return 0;

2- at the same directory, write the following and save it in a file named makefile:
default: program1
cc -o program1 program1.c

3- run the make command:

4- notice the creation of file program1, to execute it, write:

have fun.
Post a Comment