alsjinus
alsjinus

Reputation: 77

Making a Makefile of two executables in c++

I have two main program called walk.cpp and useWalker.cpp which use the class I implemented. I have the class file Walker.h and Walker.cpp, and I am required to make a Makefile which contains the target walk, the target useWalker and a target all. This is how my Makefile look like:

all:
    walk useWalker

//comment:sorry to delete the rest parts because it is a homework problem and I do not want my solution to be public. I will only keep the mistaken part.

And when I try to enter the command "make", there is an error message: walk useWalker make: walk: Command not found Makefile:2: recipe for target 'all' failed make: *** [all] Error 127

I don't know what mistake I made in my code to generate this error message and how to fix it??

Upvotes: 0

Views: 186

Answers (2)

Einheri
Einheri

Reputation: 985

The first line should read:

all: walk useWalk

Makefile language is sensitive to whitespace, and "all:" followed by a new line, a tab and "walk useWalk" means "target all depends on nothing, execute the command 'walk useWalk' to make it".

Upvotes: 4

Marcus Müller
Marcus Müller

Reputation: 36327

all:
walk useWalker

should be

all: walk useWalker

What you're doing now is asking make to run walk useWalker when you ask it to make all.

Upvotes: 1

Related Questions