缺少什么:make:***没有规则来制定目标

时间:2016-08-14 13:35:45

标签: c++ makefile

我喜欢将我的C ++环境从Windows上的Visual Studio转移到在MacOS或Ubuntu上构建简单的软件。

我这样做的测试项目(小蛇游戏)包含以下结构

Snake
|- bin
|- data
|- docs
|- lib
|- inc
   |- application
         |- app_main.h
         |- app_game_state.h
         |- app_load_map_state.h
         |- app_main_menu_state.h
         |- app_play_state.h
         |- app_shutdown_state.h
         |- app_startup_state.h
         |- app_state.h
         |- app_unload_map_state.h
   |- core
   |- graphics
   |- gui
   |- logic
   |- world
|- intern
   |- build
      |- obj
   |- tests
   |- src
      |- application
         |- Makefile
         |- main.cpp
         |- app_main.cpp
         |- app_game_state.cpp
         |- app_load_map_state.cpp
         |- app_main_menu_state.cpp
         |- app_play_state.cpp
         |- app_shutdown_state.cpp
         |- app_startup_state.cpp
         |- app_state.cpp
         |- app_unload_map_state.cpp
      |- core
      |- graphics
      |- gui
      |- logic
      |- world

Makefile的结构如下:

IDIR = ../../../inc
CC = g++
CFLAGS = -I$(IDIR)

ODIR = ../../build/obj
LDIR = ../../../lib

VPATH = ../core:../graphics/:../gui/:../logic/:../world/

_DEPS = app_game_state.h app_load_map_state.h app_main.h app_main_menu_state.h app_play_state.h app_shutdown_state.h app_startup_state.h app_state.h app_unload_map_state.h
DEPS = $(patsubst %,$(IDIR)/%,$(_DEPS))

_OBJ = main.o app_game_state.o app_load_map_state.o app_main.o app_main_menu_state.o app_play_state.o app_shutdown_state.o app_startup_state.o app_state.o app_unload_map_state.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))

$(ODIR)/%.o: %.cpp $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS)

main: $(OBJ)
    g++ -o $@ $^ $(CFLAGS) $(LIBS)

.PHONY: clean

clean:
    rm -f $(ODIR)/*.o *~core $(INCDIR)/*~

我的目标是将我从this excellent beginner tutorial on Makefiles学到的东西移植到我自己的架构中。教程make命令在我的机器上运行没有问题。所以我想我错过了什么。

由于我是Makefiles的新手,对我来说理解这些概念有点困难。即使我想了解基础知识,当我从make: *** No rule to make target '../../build/obj/main.o', needed by 'main'. Stop.运行make时,make命令会返回intern/src/application错误

为了解决这个问题,我尝试将gcc makefile error: "No rule to make target ..."的解决方案应用到我的代码中 - 但没有成功。

我的Makefile中的错误在哪里以及我不理解的内容?

修改 这里是启用了-d标志的make输出(由于消息中符号的stackoverflows限制,必须从头开始删除一些代码)

GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0
Reading makefiles...
Reading makefile `Makefile'...
...
    Looking for a rule with intermediate file `Makefile.S'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `Makefile.S'.
     Trying implicit prerequisite `Makefile.S,v'.
     Trying pattern rule with stem `Makefile.S'.
     Trying implicit prerequisite `RCS/Makefile.S,v'.
     Trying pattern rule with stem `Makefile.S'.
     Trying implicit prerequisite `RCS/Makefile.S'.
     Trying pattern rule with stem `Makefile.S'.
     Trying implicit prerequisite `s.Makefile.S'.
     Trying pattern rule with stem `Makefile.S'.
     Trying implicit prerequisite `SCCS/s.Makefile.S'.
   Trying pattern rule with stem `Makefile'.
   Rejecting impossible implicit prerequisite `Makefile.S'.
   Trying pattern rule with stem `Makefile'.
   Trying implicit prerequisite `Makefile.mod'.
   Looking for a rule with intermediate file `Makefile.mod'.
    Avoiding implicit rule recursion.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `Makefile.mod'.
    Trying implicit prerequisite `Makefile.mod,v'.
    Trying pattern rule with stem `Makefile.mod'.
    Trying implicit prerequisite `RCS/Makefile.mod,v'.
    Trying pattern rule with stem `Makefile.mod'.
    Trying implicit prerequisite `RCS/Makefile.mod'.
    Trying pattern rule with stem `Makefile.mod'.
    Trying implicit prerequisite `s.Makefile.mod'.
    Trying pattern rule with stem `Makefile.mod'.
    Trying implicit prerequisite `SCCS/s.Makefile.mod'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.c'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.cc'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.C'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.cpp'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.p'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.f'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.F'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.m'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.r'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.s'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.S'.
  Trying pattern rule with stem `Makefile'.
  Rejecting impossible implicit prerequisite `Makefile.mod'.
  Trying pattern rule with stem `Makefile'.
  Trying implicit prerequisite `Makefile.sh'.
  Looking for a rule with intermediate file `Makefile.sh'.
   Avoiding implicit rule recursion.
   Trying pattern rule with stem `Makefile.sh'.
   Trying implicit prerequisite `Makefile.sh,v'.
   Trying pattern rule with stem `Makefile.sh'.
   Trying implicit prerequisite `RCS/Makefile.sh,v'.
   Trying pattern rule with stem `Makefile.sh'.
   Trying implicit prerequisite `RCS/Makefile.sh'.
   Trying pattern rule with stem `Makefile.sh'.
   Trying implicit prerequisite `s.Makefile.sh'.
   Trying pattern rule with stem `Makefile.sh'.
   Trying implicit prerequisite `SCCS/s.Makefile.sh'.
  No implicit rule found for `Makefile'.
  Finished prerequisites of target file `Makefile'.
 No need to remake target `Makefile'.
Updating goal targets....
Considering target file `main'.
 File `main' does not exist.
  Considering target file `../../build/obj/main.o'.
   File `../../build/obj/main.o' does not exist.
   Looking for an implicit rule for `../../build/obj/main.o'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `main.cpp'.
   Trying rule prerequisite `../../../inc/app_game_state.h'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.c'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.cc'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.C'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.cpp'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.p'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.f'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.F'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.m'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.r'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.s'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.S'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.mod'.
   Trying pattern rule with stem `main.o'.
   Trying implicit prerequisite `../../build/obj/main.o,v'.
   Trying pattern rule with stem `main.o'.
   Trying implicit prerequisite `../../build/obj/RCS/main.o,v'.
   Trying pattern rule with stem `main.o'.
   Trying implicit prerequisite `../../build/obj/RCS/main.o'.
   Trying pattern rule with stem `main.o'.
   Trying implicit prerequisite `../../build/obj/s.main.o'.
   Trying pattern rule with stem `main.o'.
   Trying implicit prerequisite `../../build/obj/SCCS/s.main.o'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `main.cpp'.
   Trying rule prerequisite `../../../inc/app_game_state.h'.
   Looking for a rule with intermediate file `../../../inc/app_game_state.h'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `app_game_state.h'.
    Trying implicit prerequisite `../../../inc/app_game_state.h,v'.
    Trying pattern rule with stem `app_game_state.h'.
    Trying implicit prerequisite `../../../inc/RCS/app_game_state.h,v'.
    Trying pattern rule with stem `app_game_state.h'.
    Trying implicit prerequisite `../../../inc/RCS/app_game_state.h'.
    Trying pattern rule with stem `app_game_state.h'.
    Trying implicit prerequisite `../../../inc/s.app_game_state.h'.
    Trying pattern rule with stem `app_game_state.h'.
    Trying implicit prerequisite `../../../inc/SCCS/s.app_game_state.h'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.c'.
   Looking for a rule with intermediate file `../../build/obj/main.c'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.y'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.l'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.w'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.w'.
    Trying pattern rule with stem `main.c'.
    Trying implicit prerequisite `../../build/obj/main.c,v'.
    Trying pattern rule with stem `main.c'.
    Trying implicit prerequisite `../../build/obj/RCS/main.c,v'.
    Trying pattern rule with stem `main.c'.
    Trying implicit prerequisite `../../build/obj/RCS/main.c'.
    Trying pattern rule with stem `main.c'.
    Trying implicit prerequisite `../../build/obj/s.main.c'.
    Trying pattern rule with stem `main.c'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.c'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.y'.
    Looking for a rule with intermediate file `../../build/obj/main.y'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.y'.
     Trying implicit prerequisite `../../build/obj/main.y,v'.
     Trying pattern rule with stem `main.y'.
     Trying implicit prerequisite `../../build/obj/RCS/main.y,v'.
     Trying pattern rule with stem `main.y'.
     Trying implicit prerequisite `../../build/obj/RCS/main.y'.
     Trying pattern rule with stem `main.y'.
     Trying implicit prerequisite `../../build/obj/s.main.y'.
     Trying pattern rule with stem `main.y'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.y'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.l'.
    Looking for a rule with intermediate file `../../build/obj/main.l'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.l'.
     Trying implicit prerequisite `../../build/obj/main.l,v'.
     Trying pattern rule with stem `main.l'.
     Trying implicit prerequisite `../../build/obj/RCS/main.l,v'.
     Trying pattern rule with stem `main.l'.
     Trying implicit prerequisite `../../build/obj/RCS/main.l'.
     Trying pattern rule with stem `main.l'.
     Trying implicit prerequisite `../../build/obj/s.main.l'.
     Trying pattern rule with stem `main.l'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.l'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.w'.
    Looking for a rule with intermediate file `../../build/obj/main.w'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.w'.
     Trying implicit prerequisite `../../build/obj/main.w,v'.
     Trying pattern rule with stem `main.w'.
     Trying implicit prerequisite `../../build/obj/RCS/main.w,v'.
     Trying pattern rule with stem `main.w'.
     Trying implicit prerequisite `../../build/obj/RCS/main.w'.
     Trying pattern rule with stem `main.w'.
     Trying implicit prerequisite `../../build/obj/s.main.w'.
     Trying pattern rule with stem `main.w'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.w'.
    Trying pattern rule with stem `main'.
    Rejecting impossible implicit prerequisite `../../build/obj/main.w'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.cc'.
   Looking for a rule with intermediate file `../../build/obj/main.cc'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main.cc'.
    Trying implicit prerequisite `../../build/obj/main.cc,v'.
    Trying pattern rule with stem `main.cc'.
    Trying implicit prerequisite `../../build/obj/RCS/main.cc,v'.
    Trying pattern rule with stem `main.cc'.
    Trying implicit prerequisite `../../build/obj/RCS/main.cc'.
    Trying pattern rule with stem `main.cc'.
    Trying implicit prerequisite `../../build/obj/s.main.cc'.
    Trying pattern rule with stem `main.cc'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.cc'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.C'.
   Looking for a rule with intermediate file `../../build/obj/main.C'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main.C'.
    Trying implicit prerequisite `../../build/obj/main.C,v'.
    Trying pattern rule with stem `main.C'.
    Trying implicit prerequisite `../../build/obj/RCS/main.C,v'.
    Trying pattern rule with stem `main.C'.
    Trying implicit prerequisite `../../build/obj/RCS/main.C'.
    Trying pattern rule with stem `main.C'.
    Trying implicit prerequisite `../../build/obj/s.main.C'.
    Trying pattern rule with stem `main.C'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.C'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.cpp'.
   Looking for a rule with intermediate file `../../build/obj/main.cpp'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main.cpp'.
    Trying implicit prerequisite `../../build/obj/main.cpp,v'.
    Trying pattern rule with stem `main.cpp'.
    Trying implicit prerequisite `../../build/obj/RCS/main.cpp,v'.
    Trying pattern rule with stem `main.cpp'.
    Trying implicit prerequisite `../../build/obj/RCS/main.cpp'.
    Trying pattern rule with stem `main.cpp'.
    Trying implicit prerequisite `../../build/obj/s.main.cpp'.
    Trying pattern rule with stem `main.cpp'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.cpp'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.p'.
   Looking for a rule with intermediate file `../../build/obj/main.p'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.web'.
    Trying pattern rule with stem `main.p'.
    Trying implicit prerequisite `../../build/obj/main.p,v'.
    Trying pattern rule with stem `main.p'.
    Trying implicit prerequisite `../../build/obj/RCS/main.p,v'.
    Trying pattern rule with stem `main.p'.
    Trying implicit prerequisite `../../build/obj/RCS/main.p'.
    Trying pattern rule with stem `main.p'.
    Trying implicit prerequisite `../../build/obj/s.main.p'.
    Trying pattern rule with stem `main.p'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.p'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.web'.
    Looking for a rule with intermediate file `../../build/obj/main.web'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.web'.
     Trying implicit prerequisite `../../build/obj/main.web,v'.
     Trying pattern rule with stem `main.web'.
     Trying implicit prerequisite `../../build/obj/RCS/main.web,v'.
     Trying pattern rule with stem `main.web'.
     Trying implicit prerequisite `../../build/obj/RCS/main.web'.
     Trying pattern rule with stem `main.web'.
     Trying implicit prerequisite `../../build/obj/s.main.web'.
     Trying pattern rule with stem `main.web'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.web'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.f'.
   Looking for a rule with intermediate file `../../build/obj/main.f'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.F'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.r'.
    Trying pattern rule with stem `main.f'.
    Trying implicit prerequisite `../../build/obj/main.f,v'.
    Trying pattern rule with stem `main.f'.
    Trying implicit prerequisite `../../build/obj/RCS/main.f,v'.
    Trying pattern rule with stem `main.f'.
    Trying implicit prerequisite `../../build/obj/RCS/main.f'.
    Trying pattern rule with stem `main.f'.
    Trying implicit prerequisite `../../build/obj/s.main.f'.
    Trying pattern rule with stem `main.f'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.f'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.F'.
    Looking for a rule with intermediate file `../../build/obj/main.F'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.F'.
     Trying implicit prerequisite `../../build/obj/main.F,v'.
     Trying pattern rule with stem `main.F'.
     Trying implicit prerequisite `../../build/obj/RCS/main.F,v'.
     Trying pattern rule with stem `main.F'.
     Trying implicit prerequisite `../../build/obj/RCS/main.F'.
     Trying pattern rule with stem `main.F'.
     Trying implicit prerequisite `../../build/obj/s.main.F'.
     Trying pattern rule with stem `main.F'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.F'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.r'.
    Looking for a rule with intermediate file `../../build/obj/main.r'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main'.
     Rejecting impossible implicit prerequisite `../../build/obj/main.l'.
     Trying pattern rule with stem `main.r'.
     Trying implicit prerequisite `../../build/obj/main.r,v'.
     Trying pattern rule with stem `main.r'.
     Trying implicit prerequisite `../../build/obj/RCS/main.r,v'.
     Trying pattern rule with stem `main.r'.
     Trying implicit prerequisite `../../build/obj/RCS/main.r'.
     Trying pattern rule with stem `main.r'.
     Trying implicit prerequisite `../../build/obj/s.main.r'.
     Trying pattern rule with stem `main.r'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.r'.
   Trying pattern rule with stem `main'.
   Rejecting impossible implicit prerequisite `../../build/obj/main.F'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.m'.
   Looking for a rule with intermediate file `../../build/obj/main.m'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.ym'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.lm'.
    Trying pattern rule with stem `main.m'.
    Trying implicit prerequisite `../../build/obj/main.m,v'.
    Trying pattern rule with stem `main.m'.
    Trying implicit prerequisite `../../build/obj/RCS/main.m,v'.
    Trying pattern rule with stem `main.m'.
    Trying implicit prerequisite `../../build/obj/RCS/main.m'.
    Trying pattern rule with stem `main.m'.
    Trying implicit prerequisite `../../build/obj/s.main.m'.
    Trying pattern rule with stem `main.m'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.m'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.ym'.
    Looking for a rule with intermediate file `../../build/obj/main.ym'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.ym'.
     Trying implicit prerequisite `../../build/obj/main.ym,v'.
     Trying pattern rule with stem `main.ym'.
     Trying implicit prerequisite `../../build/obj/RCS/main.ym,v'.
     Trying pattern rule with stem `main.ym'.
     Trying implicit prerequisite `../../build/obj/RCS/main.ym'.
     Trying pattern rule with stem `main.ym'.
     Trying implicit prerequisite `../../build/obj/s.main.ym'.
     Trying pattern rule with stem `main.ym'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.ym'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.lm'.
    Looking for a rule with intermediate file `../../build/obj/main.lm'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.lm'.
     Trying implicit prerequisite `../../build/obj/main.lm,v'.
     Trying pattern rule with stem `main.lm'.
     Trying implicit prerequisite `../../build/obj/RCS/main.lm,v'.
     Trying pattern rule with stem `main.lm'.
     Trying implicit prerequisite `../../build/obj/RCS/main.lm'.
     Trying pattern rule with stem `main.lm'.
     Trying implicit prerequisite `../../build/obj/s.main.lm'.
     Trying pattern rule with stem `main.lm'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.lm'.
   Trying pattern rule with stem `main'.
   Rejecting impossible implicit prerequisite `../../build/obj/main.r'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.s'.
   Looking for a rule with intermediate file `../../build/obj/main.s'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.S'.
    Trying pattern rule with stem `main.s'.
    Trying implicit prerequisite `../../build/obj/main.s,v'.
    Trying pattern rule with stem `main.s'.
    Trying implicit prerequisite `../../build/obj/RCS/main.s,v'.
    Trying pattern rule with stem `main.s'.
    Trying implicit prerequisite `../../build/obj/RCS/main.s'.
    Trying pattern rule with stem `main.s'.
    Trying implicit prerequisite `../../build/obj/s.main.s'.
    Trying pattern rule with stem `main.s'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.s'.
    Trying pattern rule with stem `main'.
    Trying implicit prerequisite `../../build/obj/main.S'.
    Looking for a rule with intermediate file `../../build/obj/main.S'.
     Avoiding implicit rule recursion.
     Avoiding implicit rule recursion.
     Trying pattern rule with stem `main.S'.
     Trying implicit prerequisite `../../build/obj/main.S,v'.
     Trying pattern rule with stem `main.S'.
     Trying implicit prerequisite `../../build/obj/RCS/main.S,v'.
     Trying pattern rule with stem `main.S'.
     Trying implicit prerequisite `../../build/obj/RCS/main.S'.
     Trying pattern rule with stem `main.S'.
     Trying implicit prerequisite `../../build/obj/s.main.S'.
     Trying pattern rule with stem `main.S'.
     Trying implicit prerequisite `../../build/obj/SCCS/s.main.S'.
   Trying pattern rule with stem `main'.
   Rejecting impossible implicit prerequisite `../../build/obj/main.S'.
   Trying pattern rule with stem `main'.
   Trying implicit prerequisite `../../build/obj/main.mod'.
   Looking for a rule with intermediate file `../../build/obj/main.mod'.
    Avoiding implicit rule recursion.
    Trying pattern rule with stem `main.mod'.
    Trying implicit prerequisite `../../build/obj/main.mod,v'.
    Trying pattern rule with stem `main.mod'.
    Trying implicit prerequisite `../../build/obj/RCS/main.mod,v'.
    Trying pattern rule with stem `main.mod'.
    Trying implicit prerequisite `../../build/obj/RCS/main.mod'.
    Trying pattern rule with stem `main.mod'.
    Trying implicit prerequisite `../../build/obj/s.main.mod'.
    Trying pattern rule with stem `main.mod'.
    Trying implicit prerequisite `../../build/obj/SCCS/s.main.mod'.
   No implicit rule found for `../../build/obj/main.o'.
   Finished prerequisites of target file `../../build/obj/main.o'.
  Must remake target `../../build/obj/main.o'.

2 个答案:

答案 0 :(得分:3)

规则的依赖关系

$(ODIR)/%.o: %.cpp $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS)

不满意:make找到main.cpp确定它找不到$(DEPS)的依赖关系。您可以通过将IDIR指向正确的目录来解决问题:

IDIR = = ../../../inc/application

不可否认,错误信息并非完全有用。

答案 1 :(得分:0)

我不知道为什么你的隐含规则不起作用。

$(ODIR)/%.o: %.cpp $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS)

但是,在它的位置,请尝试使用以下static pattern rule来制作目标文件:

$(OBJ): $(ODIR)/%.o: %.cpp $(DEPS)
    $(CC) -c -o $@ $< $(CFLAGS)

这里提出了一个非常类似的问题 - GNU Make pattern to build output in different directory than src。我尝试了你所展示的目录设置的答案,并且它有效。

如果我应该将此添加为评论,请告诉我。我无法弄清楚哪个是对的。