unix - No rule to make target in Maefile -
i'm learning write makefiles. made own simple 1 try , test, every time run make, get:
make: *** no rule make target `/%.cpp', needed `obj'. stop.
i googled. i'm pretty sure typed correctly, , folders set way should be. here makefile:
cc = g++ ld = g++ name = app obj_dir = obj src_dir = src cc_flags = -std=c++0x all: $(name) $(name): $(obj_dir)/%.o $(ld) $(obj_dir)/%.o -o $@ $(obj_dir)/%.o: $(src_dir)/%.cpp $(cc) $< -o $@ $(cc_flags) clean: rm $(name) $(obj_dir) -rf
what problem?
the line:
$(name): $(obj_dir)/%.o
is not correct. not pattern rule (because target doesn't contain pattern character, %
) , it's interpreted explicit rule, saying app
depends on actual file named obj/%.o
doesn't exist, , make doesn't know how build (because there's no file src/%.cpp
).
you need change to:
$(name): $(obj_dir)/foo.o ...
or whatever object files have.
Comments
Post a Comment