Want to know how to make multiple directory dependencies

Asked 1 years ago, Updated 1 years ago, 304 views

Question details

Regarding the makefile below, I don't know why the following error occurs.
If it's one directory, it's successful, but if there are two, what should I do?
I just need to write two variables in the same dependent location and write the command normally, but it doesn't work.

What did you know

I want to know how to get the following console screen errors

Tried

There are two directories of files that depend on reference sites, so $< is $^ to specify all dependent files

Reference Site

Automatic variables: https://tex2e.github.io/blog/makefile/automatic-variables
How to write dependencies: https://www.unixuser.org/~euske/doc/makefile/

directory structure

FrameWork/bin/program
FrameWork/src/.cpp
FrameWork/src/
.hpp
FrameWork/src/component/.cpp
FrameWork/src/component/
.hpp
FrameWork/Makefile

console

$sh run.sh
make: *** 'bin/libFrameWork.a' has no rule to make the required target 'obj/BoxCollider2D.o'. Stop.


    FrameWork Compile Error



Makefile

PRG:=bin/libFrameWork.a

SRC_DIR: =src
SRC_COMPONENT_DIR: =src/component

OBJ_DIR: = obj
DEP_DIR: =obj
DEP: =$(wildcard$(DEP_DIR)/*.d)

SRC: =$(wildcard$(SRC_DIR)/*.cpp)
SRC_COMPONENT: =$(wildcard$(SRC_COMPONENT_DIR)/*.cpp)

OBJ_COMPONENT: =$(addprefix$(OBJ_DIR)/,$(patsubst%.cpp,%.o,$(notdir$(SRC_COMPONENT)))))
OBJ: =$(addprefix$(OBJ_DIR)/,$(patsubst%.cpp, %.o, $(notdir$(SRC)))))


$(PRG): $(OBJ)$(OBJ_COMPONENT) 
#   arcs$@$(OBJ)$(OBJ_COMPONENT)
    arrcs$@$^

$(OBJ_DIR)/%.o: src/%.cpp src/component/%.cpp
#   $(CXX)-c-MMD-MP$<-o$@-I~/Library-I~/Library/freeetype 
    $(CXX)-c-MMD-MP$^-o$@-I~/Library-I~/Library/freetype 
-include$(DEP)

US>clean:
    rm-f./$(OBJ_DIR)/*.o*.out./$(OBJ_DIR)/*.d$(PRG)

makefile

2022-12-25 07:48

1 Answers

I think the rule description is wrong.
Specifically, I think it would be good to describe the following in two rules.

Before:

$(OBJ_DIR)/%.o:src/%.cpp src/component/%.cpp
    $(CXX)-c-MMD-MP$^-o$@-I~/Library-I~/Library/freetype

After:

$(OBJ_DIR)/%.o:src/%.cpp
    $(CXX)-c-MMD-MP$^-o$@-I~/Library-I~/Library/freetype

$(OBJ_DIR)/%.o: src/component/%.cpp
    $(CXX)-c-MMD-MP$^-o$@-I~/Library-I~/Library/freetype

For obj/BoxCollider2D.o, the rule before the change seems to be interpreted as follows:

obj/BoxCollider2D.o:src/BoxCollider2D.cpp src/component/BoxCollider2D.cpp
    $(CXX)-c-MMD-MP$^-o$@-I~/Library-I~/Library/freetype

(I can't read the source file in which directory from the question, so I'll write it down as being in src)
src/BoxCollider2D.cpp exists, so there is no src/component/BoxCollider2D.cpp, so make attempts to generate this file.
However, since there is no generation rule for src/component/BoxCollider 2D.cpp, the original rule does not apply as a result.

# If you run make-d to see how it works, the output will be
If it doesn't work the way you want it to, you should take a look at it.


2022-12-25 21:09

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.