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: Jed Brown
Subject: Re: Using "-l" libraries as targets
Date: Tue, 02 Jun 2015 18:33:04 +0200
User-agent: Notmuch/0.19+110~gea782ec (http://notmuchmail.org) Emacs/25.0.50.1 (x86_64-unknown-linux-gnu)

Paul Smith <address@hidden> writes:
> 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.

Even that will typically prefer ./libfoo.so over ./libfoo.a unless
you're also using -static or similar.

> 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.

I've never heard of this and it's certainly not the case that writing
libfoo.a pulls in unreferenced symbols with default linker options.
Normally that is achieved by

  -Wl,-whole-archive libfoo.a -Wl,-no-whole-archive

Attachment: signature.asc
Description: PGP signature


reply via email to

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