user1007531
user1007531

Reputation: 31

A simple (trivial) c++ makefile on UNIX

I am trying to make a makefile for one cpp file. I've tried googling and none of the examples I've seen have helped... I keep getting errors when I type make. Here is what I have...

      Interpreter: Interpreter.o
           g++ -o Interpreter Interpreter.o

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

When I type make I get this error... "'ake: Fatal error: Don't know how to make target `Interpreter.o"

Where am I going wrong?

Upvotes: 0

Views: 433

Answers (1)

T.E.D.
T.E.D.

Reputation: 44814

OK. A few simple things to start with here:

  • As mentioned in some of the comments, the makefile file must be named properly for make to find it. You can try specifing it manually with the -f flag to verify that it is being found.

  • Make is one of those few unfortunate languages where whitespace is important. The rules must not have a tab in front of them, and the commands for the rules should all have exactly one tab in front of them. When I checked your code above in the SO editor, it looked like your commands had two tabs at the front instead of one.

  • If I'm reading those rules right, you need a file named Interpreter.cpp in your working directory for this to work. If you don't have that file, you'll get an error.

  • If all else fails, try running make with the debugging flag (-d). This should give you more information about the decisions it is making.

Upvotes: 1

Related Questions