Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie Makefile question

Status
Not open for further replies.

KR3M3R

Programmer
Mar 31, 2008
1
US
I am trying to write a makefile for a school project.

When I type:
g++ -o simulator simulator.cpp

I get the output:
simulator

Which is what I want. In my makefile I've typed:

# The target
simulator : simulator.cpp
g++ -o simulator simulator.cpp
# To generate the class files
simulator.o : simulator.cpp
g++ -c simulator.cpp
# clean out the dross
clean:
rm simulator.o

But it doesn't work and I've no idea how to make it work I've searched forums and google and can't find out what's wrong.

Currently I'm getting the error:
'ake: Fatal error: Don't know how to make target `simulator.cpp

Any help would be greatly appreciated.
-Robb
 
1) makefiles are fussy - they need tabs and not spaces. The syntax is

itemreqd: dependency
<tab>how to do it
<blank line>

2) You don't need the rule to make the class file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top