help-make
[Top][All Lists]
Advanced

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

Re: Using "-l" libraries as targets


From: Paul Smith
Subject: Re: Using "-l" libraries as targets
Date: Mon, 01 Jun 2015 08:11:38 -0400

On Mon, 2015-06-01 at 20:57 +0900, Luke Allardyce wrote:
> 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?

Correct.  The -l version is only expanded in prerequisites.  This
feature is only available so you can write a rule like this:

  foo: foo.o -lfoo
          $(LINK.c) -o $@ $^

and have it work properly (that is, add "foo.o -lfoo" to the link line
as the expansion of "$^").  Fancy support for "-lfoo" is not needed in a
target context, because no tools build targets named "-lfoo".

> The following works
> 
> main.exe: -lfoo
> -lfoo libfoo.a: libfoo.a(foo.o) ;

You can remove the "-lfoo" from the target line altogether; it's
useless:

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




reply via email to

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