0

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)
PentiumPro200
  • 641
  • 7
  • 23
  • 1
    Post a [MCVE] please. – user657267 Aug 11 '16 at 22:25
  • This question is highly unclear. If you want Make to rebuild the object files in the current directory even when they already exist somewhere else, then why use VPATH at all? – Beta Aug 12 '16 at 02:00

0 Answers0