Tutorials Point


  Makefile Tutorial
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

Makefile Example

previous next AddThis Social Bookmark Button


This is an example of the Makefile for compiling the hello program. This program consists of three files main.cpp, factorial.cpp and hello.cpp.

# Define required macros here
SHELL = /bin/sh

OBJ =  main.o factorial.o hello.o
CFLAG = -Wall -g
CC = gcc
INCLUDE =
LIB = -lm

hello:${OBJ}
   ${CC} ${CFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}

clean:
	-rm -f *.o core *.core

.cpp.o:
   ${CC} ${CFLAGS} ${INCLUDES} -c $<

Now you can build your program hello using "make". If you will issue a command "make clean" then it will remove all the object files and core files available in the current directory.



previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names