Reputation: 1352
This is my Makefile :
NAME = pong
SRCS = src/main.cpp
OBJS = $(SRCS:.cpp=.o)
CFLAGS += -lsfml-graphics -lsfml-window -lsfml-system -I include/
all: $(NAME)
$(NAME): $(OBJS)
g++ -o $(NAME) $(SRCS) $(CFLAGS)
clean:
rm -f $(OBJS)
fclean: clean
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re
When I do make
, it tells me that the header I include in my main.ccp does not exist.
#include "prototypes.hpp"
This is my project organisation :
.
├── a.out
├── include
│ └── prototypes.hpp
├── Makefile
├── src
│ └── main.cpp
└── test
And the weirdest thing is that this work when I do
g++ -o test src/main.cpp -lsfml-graphics -lsfml-window -lsfml-system -I include/
Any idea why ?
Upvotes: 0
Views: 1567
Reputation: 1
With your rule
$(NAME): $(OBJS)
the dependency on $(OBJS)
will run make
s implicit ℅.o : ℅.cpp
rule first, which in turn uses $CXXFLAGS
and thus doesn't see the -I
option.
As your rule is written, just omit the dependency on $(OBJS)
.
Upvotes: 1