I'm trying to link a bunch of object files into a shared object. I specify the location of some of the object files which are located in a different directory using VPATH. If the .o file exists in that directory, then I get an error message that g++ cannot find the .o file. If I delete the object files in the other directory, then GNU Make / GCC compiles the .o in the current directory from the .c in the other directory specified by the VPATH. So how can I change my makefile so that the pre-requisite object files are always built in the current directory even if the object file exists in the other directory specified by the VPATH?
Here's my main make rule:
LD = g++ -g -shared
ALGOBJ = <a bunch of object files>
$(PROGRAM): $(ALGOBJ)
$(LD) -Wl,-soname -Wl,.so -Wl,--no-undefined $(LDPTHS) -o $(PROGRAM) $(ALGOBJ)