I'm trying to move the *.o-files into a separate folder (/objs). But I'm getting the following error:
"No rule to make target '../objs/main.o', needed by 'all'. Stop."
How do I have to define these rules? My folder structure looks as follows:
model_1/
main.cpp
Model1.cpp
Model1.h
model_1.mk # Makefile
pub_sub/
...
objs/
My Makefile:
CC=gcc
CXX=g++
RM=rm -f
PROG = myProgram
INCLUDES = -I../pub_sub
CXXFLAGS := -std=c++1y -g -Wall ${INCLUDES}
LDFLAGS = -L/usr/local/lib
SRCS= main.cpp Model1.cpp ../pub_sub/Subscriber.cpp ../pub_sub/Publisher.cpp
OBJS= $(addprefix ../objs/, $(notdir $(subst .cpp,.o,$(SRCS))))
all: $(OBJS)
$(CXX) $(CXXFLAGS) -o $(PROG) $(OBJS) $(LDFLAGS)
.PHONY:
clean:
$(RM) $(OBJS)
distclean: clean
$(RM) $(PROG)