Subject: deplibs lossage
To: None <tech-toolchain@netbsd.org>
From: Jaromír Doleček <dolecek@ibis.cz>
List: tech-toolchain
Date: 07/07/2000 11:50:42
Hi,
is there any reason why ld on i386-elf doesn't look for hardcoded
library paths in libraries it links programs against and doesn't
automatically put them also into resulting binary ?

eg. I have
dolecek~ > ldd /usr/pkg/lib/libgd.so.1.9
/usr/pkg/lib/libgd.so.1.9:
         -lm.0 => /usr/lib/libm387.so.0
         -lm.0 => /usr/lib/libm.so.0
         -lc.12 => /usr/lib/libc.so.12
         -lpng.1 => /usr/pkg/lib/libpng.so.1
         -lz.0 => /usr/lib/libz.so.0
         -ljpeg.62 => /usr/pkg/lib/libjpeg.so.62
         -lttf.3 => /usr/pkg/lib/libttf.so.3
         -lXpm.4 => /usr/X11R6/lib/libXpm.so.4
         -lX11.6 => /usr/X11R6/lib/libX11.so.6

yet when I link simple program against it
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char gdImagePaletteCopy();

int main() {
gdImagePaletteCopy()
; return 0; }

linker spews:

/usr/bin/ld: warning: libpng.so.1, needed by /usr/pkg/lib/libgd.so, not found (try using --rpath)
/usr/bin/ld: warning: libjpeg.so.62, needed by /usr/pkg/lib/libgd.so, not found (try using --rpath)
/usr/bin/ld: warning: libttf.so.3, needed by /usr/pkg/lib/libgd.so, not found (try using --rpath)
/usr/bin/ld: warning: libXpm.so.4, needed by /usr/pkg/lib/libgd.so, not found (try using --rpath)
/usr/bin/ld: warning: libX11.so.6, needed by /usr/pkg/lib/libgd.so, not found (try using --rpath)
/usr/pkg/lib/libgd.so: undefined reference to `png_set_dither'
/usr/pkg/lib/libgd.so: undefined reference to `TT_New_Glyph'
... lots of other undefined references ...

So apparently ld doesn't know about the paths hardcoded into libgd library.

I had to adjust gd compile from pkgsrc a little to force the resulting
libgd.so be linked against other dependant libraries, it's possible
I screwed it somehow. Though ldd on libgd.so would also fail
if the library would be incorrect, right ?

And BTW, this whole -R/--rpath crap just plain sucks. We should do
what SunOS does - hardcode all paths passed to -L by default,
or only those specified by -R/--rpath if it was passed.
Adjusting build of every program on the earth to pass the flags
is highly annoying.

Jaromir
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
@@@@  Wanna a real operating system ? Go and get NetBSD, damn!  @@@@