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 Aug 12 17:39:00 GMT 2003


On Tue, Aug 12, 2003 at 09:44:28AM -0700, Ian Lance Taylor wrote:
> David Wuertele <dave-gnus@bfnet.com> writes:
> 
> > I want to create a dynamic library, libA, that links with libB.  Then
> > I want to create an executable that links with libA.  But I don't want
> > to have to have libB around at compile time.  But gcc/ld complains if
> > libB.so is not there!  Why is that?  My executable only makes calls to
> > libA.  The dynamic loader should take care of libB, not the linker!
> > 
> > In windows, you can do what I want.  I've constructed two scripts, one
> > for Linux using gcc/ld, and one for windows using cl/link, to
> > demonstrate what I want to do and what is going wrong in Linux.  Can
> > anyone tell me how to achieve this with gcc/ld?
> 
> I think this is a bug.  The GNU linker is reporting an error where it
> should report a warning.
> 
> Any comments on this patch?
> 

I prefer something like this.


H.J.
----
--- bfd/elflink.h.undef	2003-08-07 09:04:31.000000000 -0700
+++ bfd/elflink.h	2003-08-12 10:38:32.000000000 -0700
@@ -4380,7 +4380,7 @@ elf_link_output_extsym (struct elf_link_
     {
       if (! ((*finfo->info->callbacks->undefined_symbol)
 	     (finfo->info, h->root.root.string, h->root.u.undef.abfd,
-	      NULL, 0, TRUE)))
+	      NULL, 0, ! finfo->info->allow_shlib_undefined)))
 	{
 	  eoinfo->failed = TRUE;
 	  return FALSE;



More information about the Binutils mailing list