I'm trying to compile a project in C ++ using the following makefile code:
OBJS = main.o src.o
SDIR = ./src
IDIR = ./include
BDIR = ./bin/
ODIR = $(BDIR)/obj
all: main
%.o: $(SDIR)/%.cpp $(IDIR)/%.h
g++ -c -o $(ODIR)/$@ $(SDIR)/$< -I $(IDIR)
main: $(OBJS)
g++ -o $@ $^ -I $(IDIR)
When I try to compile the program the following error appears in the terminal:
xxxx@zzz:$ make
g++ -c -o main.o main.cpp
main.cpp:2:17: fatal error: src.h: Arquivo ou diretório não encontrado
#include "src.h"
^
compilation terminated.
<builtin>: recipe for target 'main.o' failed
make: *** [main.o] Error 1
But the 'src.h' file exists and is within the include suffix. Then I would like to know the reason for the error.