Reputation: 18242
I have 4 components:
My executables should be Bin1
and Bin2
- MainA
and MainB
use ImplA
and ImplB
, respectively. My makefile is:
CC=g++
CCOPTS=-g -w
OBJS = $(BINDIR)/MainA.o $(BINDIR)/MainB.o $(BINDIR)/ImplA.o $(BINDIR)/ImplB.o
TARGETS = $(BINDIR)/Bin1 $(BINDIR)/Bin2
BINDIR = build
all: $(TARGETS) $(OBJS)
clean:
rm -f $(TARGETS) $(OBJS)
.PHONY: all clean
$(BINDIR)/Bin1 : $(BINDIR)/MainA.o $(BINDIR)/ImplA.o
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
$(BINDIR)/Bin2 : $(BINDIR)/MainB.o $(BINDIR)/ImplB.o
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
$(BINDIR)/%.o: %.cpp
$(CC) -c $(CCOPTS) -o $@ $<
When I attempt to make, I get:
g++ -c -g -w -o build/MainA.o MainA.cpp
Assembler messages:
Fatal error: can't create build/MainA.o: No such file or directory
make: *** [build/MainA.o] Error 1
What don't I understand?
Upvotes: 0
Views: 53