help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using "-l" libraries as targets


From: Luke Allardyce
Subject: Using "-l" libraries as targets
Date: Mon, 1 Jun 2015 20:57:22 +0900

I was trying to take advantage of make's library lookup to force a
local copy of the lib source to build if it can't find one already
installed when I came across the following.

The Makefile below (assuming two source files foo.cpp and
main.exe.cpp) forces main.exe to relink on every run

main.exe: -lfoo
-lfoo: libfoo.a(foo.o) ;

Relevant debug info below

  No need to remake target '-lfoo'; using VPATH name 'libfoo.a'.
 Finished prerequisites of target file 'main.exe'.
 Prerequisite 'main.exe.cpp' is older than target 'main.exe'.
 Prerequisite 'libfoo.a' of target 'main.exe' does not exist.
Must remake target 'main.exe'

It's kind of strange that make seems to determine that the lib doesn't
need remaking but can't then find it, but the manual only mentions
when "-l" is a prerequisite so are they simply not supported when used
as targets on their own like this?

The following works

main.exe: -lfoo
-lfoo libfoo.a: libfoo.a(foo.o) ;

although make will always prefer the local copy of the lib.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]