我的MakeFile找不到我的标头目录 [英] My MakeFile can't find my header directory
本文介绍了我的MakeFile找不到我的标头目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的Makefile:
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
当我执行 make
时,它告诉我main.ccp中包含的标头不存在.
When I do make
, it tells me that the header I include in my main.ccp does not exist.
#include "prototypes.hpp"
这是我的项目组织:
.
├── 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/
知道为什么吗?
推荐答案
遵循您的规则
$(NAME): $(OBJS)
对 $(OBJS)
的依赖将首先运行 make
隐式℅.o:℅.cpp
规则,该规则反过来使用 $ CXXFLAGS
,因此看不到 -I
选项.
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.
在编写规则时,只需忽略对 $(OBJS)
的依赖.
As your rule is written, just omit the dependency on $(OBJS)
.
这篇关于我的MakeFile找不到我的标头目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文