Sean
Sean

Reputation: 4525

is that necessary for makefile to generate .o files for small projects

all: hello

hello: main.o
 g++ -o hello main.o

main.o: main.cpp
 g++ -c main.cpp

Above is a simple makefile, my question is that why we do not use the following for small project? It is no need to generate .o files. Is there any disadvantage of using the following format for small projects?

all: hello

hello:main.cpp
 g++ -o hello main.cpp

Upvotes: 1

Views: 107

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272617

No, there is no disadvantage.

[Of course, simple projects have a tendency to grow into bigger projects, so there's always an argument that you should start as you mean to go on...]

Upvotes: 3

Related Questions