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: Tue, 02 Jun 2015 12:26:00 -0400

On Tue, 2015-06-02 at 17:46 +0200, Jed Brown wrote:
> Paul Smith <address@hidden> writes:
> > I think it's better to just always use "libfoo.a" as a prerequisite, if
> > that's what you want.  It's easy enough to use patsubst in the recipe to
> > convert them to -l options, if you want:
> >
> >    $(LINK.cc) -o $@ $(patsubst lib%.a,-l%,$^)
> 
> But please don't do this because some day someone will have a libfoo.so
> in their path and they'll (a) give up on your software, (b) write you
> with an incomprehensible support request and waste your time, or (c)
> curse you for wasting their time.  Explicit is better here.

Well, of course I was assuming that your link line would add "-L." or
similar so that you know that the local directory is always searched
first.

I don't have time to check it to be sure, but I have a vague memory that
"-lfoo" and "libfoo.a" are not equivalent to the linker: for the former
the linker only pulls in objects which contain symbols that are actually
needed, while in the latter the link unconditionally pulls in all the
objects in the library.  But I could be imagining this.




reply via email to

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