How do I link to a shared lib without having that lib's dependencies (the way MS link does)

H. J. Lu hjl@lucon.org
Tue Apr 26 00:40:00 GMT 2005


On Mon, Apr 25, 2005 at 04:42:30PM -0700, David Wuertele wrote:
> HJL> Here is something you can try. You need to pass
> HJL> 	-Wl,--ignore-needed libA.so -Wl,--no-ignore-needed
> HJL> to gcc.
> 
> I was hoping for something simpler that I could give to users of my
> SDK.  I don't mind warnings, I just mind the erroring out when there

If you want to give your users a libA.so, which isn't fully functional
at link-time, why not give them a dummy libA.so with the same ABI
for link-time only? I assume your run-time environment is different
from link-time. Of course, they can't use the dummy libA.so for the
the run-time environment.

> is really no error.  Does anyone besides me consider the default
> functionality to be broken?
> 
> Is the "-Wl,--no-ignore-needed" necessary?  Will omitting it cause ld
> to ignore linking errors that really are errors?

"-Wl,--no-ignore-needed" is needed so that the libraries after libA.so
will be treated normally.


H.J.



More information about the Binutils mailing list