On Sun, 9 Jan 2005, Doron Bleiberg wrote: > Hi, > How can I link several object files which located under different > directories to one executable ? > For example, I want to call > app: a.o b.o c.o > g++ a.o b.o c.o -o app > > a.o: ... > > and lets say that a.o is created locally (using the example make) while b.o > and c.o are object files precompiled by other user and which located under > different directory in the file system. > I want the command: make app, to locate and link b.o and c.o automatically > by searching predefined directory path. I don't want to copy manually all > the needed objects before linking time. > I know that I can use VPATH for the prerequisites, but how can I search for > files in the Link stage ?
as i understand it, if you read http://www.gnu.org/software/make/manual/html_chapter/make_4.html#SEC34 section 4.5.4, you'll see that, once VPATH takes care of *finding* the prerequisites, you can refer to those prerequisites with respect to their actual locations with the special variable "$^". as it states: "the value of `$^' is a list of all the prerequisites of the rule, including the names of the directories in which they were found..." so you would write: app: a.o b.o c.o g++ $^ -o app rday _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
