Note that there are some explanatory texts on larger screens.

plurals
  1. POMake searches dependencies in the wrong place
    text
    copied!<p>I'm relatively new to (GNU) Make, and find it incedibly difficult. I consider switching to SCons, but still, I'd like to understand.</p> <p>I have a makefile in a folder, that contains subdirectories ./src, ./obj/[release|debug] and ./bin[release|debug]. The makefile should be able to grab the C++ sources in ./src, compile them into object files in the appropriate ./obj directory, and link these object files and put the result in the appropriate ./bin directory. Here is my makefile (edited for simplicity):</p> <pre><code>CONFIG = release #CONFIG = debug OBJS = Container.o OBJDIR = obj/$(CONFIG) BINDIR = bin/$(CONFIG) VPATH = src $(BINDIR) vpath %.o $(OBJDIR) .PHONY: release release: $(OBJS) $(CXX) $(LXXFLAGS) -o $(BINDIR)/$@ $^ Container.o: Container.cpp Container.hpp $(CXX) -c $(CXXFLAGS) -o $(OBJDIR)/$@ $&lt; </code></pre> <p>The first time I run make, the "release" target will search for "Container.o" in the current folder, as well as in $(OBJDIR). Failing to find it, the secong target will be correctly executed, generating the object file in the correct folder. The "release" target will then execute, but the linker will complain that "Container.o" is not found...</p> <p>The second time I run make, the "release" target will search for "Container.o" and find it in $(OBJDIR). The linker will then execute correctly (the path where "Container.o" has been found is prepended to the filename).</p> <p>Is there a way to make it work in a single pass? It drives me crazy!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload