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: Luke Allardyce
Subject: Re: Using "-l" libraries as targets
Date: Mon, 1 Jun 2015 21:21:51 +0900

 That results in "make: *** No rule to make target '-lfoo', needed by
'main.exe'.  Stop.", unless of course libfoo.a is already installed.

On 1 June 2015 at 21:11, Paul Smith <address@hidden> wrote:
> 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]