Frage

I tried running the following Makefile

SRC=../src
INC=../inc

OBJS=$(SRC)/rrbsSimulator.o \
     $(SRC)/XMLParser.o

ALLOBJS=rrbsSimulator.o \
        XMLParser.o

CC=/usr/sfw/bin/gcc

FLAGS= -Wall -g -m64

AINC=-I$(INC)
ALLLIBS=-lcc -lsocket -lnsl -lpthread -lstdc++

%.o: %.cpp
   $(CC) $(AINC) $(FLAGS) -c $<

lcc: $(ALLOBJS)
   $(CC)  $(FLAGS) $(ALLLIBS) $(ALLOBJS) -o lycaUSSDSIM
   mv lycaUSSDSIM ../bin


clean:
   rm -f $(ALLOBJS)  ../bin/lycaUSSDSIM

I am getting the following error

make: Fatal error: Don't know how to make target `rrbsSimulator.o'

What is the mistake I have done?

War es hilfreich?

Lösung

The error Don't know how to make targetrrbsSimulator.o'` means one of two things. Either

  1. There is no rule that can make this file, or
  2. There is a rule, but its dependencies cannot be made (or found).

This looks like a valid rule.

%.o: %.cpp
   $(CC) $(AINC) $(FLAGS) -c $<

Therefore the most likely cause is that its dependency, with the suffix of cpp, is missing. Look for rrbsSimulator.cpp in the relevant source folder.

Unfortunately makefiles used by some legacy versions of make are ridiculously picky over formatting like spaces and tabs, and it's not possible to see those in this format. If you are using one of those makes you need to check the whitespace carefully.

Andere Tipps

Where do your source files situated?

Looking at SRC and OBJS variables I can imagine that your source code files are placed in ../src folder. But %.o : %.cpp will search for both *.o and *.cpp files in the current directory. Thus it would not find neither rrbsSimulator.o nor rrbsSimulator.cpp.

Btw, why don't you use a standard CFLAGS variable instead of yourown FLAGS? and you better write it this way:

FLAGS += -Wall -g -m64

What if you would like to add some extra flags from command line later on? This will let you call your makefile in this way:

make FLAGS=-s

Add VPATH = $(SRC) it will work. Also need to concentrate with spacing when we implementing Makefile.

rrbsSimulator.cpp does not exist.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top