[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: PW#5-7: Linking shared libraries with -lc



On Fri, 23 Jan 1998 jdassen@wi.leidenuniv.nl wrote:

> IMO, shared libraries should use `-lsomelib' for each library they directly
> depend on, not just `-lc'. For example, the LessTif shared library depends
> directly on Xt, Xext, X11 (and through them on other X libs). I have linked
> it "-lXt -lXext -lX11 -lc".  Thus, ldd can show proper dependencies on all
> libraries it depends on:

I'm don't think this is a good idea. I thought so, but after I saw what
happens when you do things this way... whoops, not good.

Let's say you have a library that provides an interface to several graphic
formats (png, tiff, jpeg), and you write a program where you use only the
png related functions, and NEVER touch tiff or jpeg. If the library is
built in the way you (and I, until a few days ago) propose you end up with
a program linked against the libraries proving the functions for png, tiff
and jpeg.  If those libraries are not in use before the program runs, they
are loaded, and the memory requierements for your program increases, a
lot. The GNU linker is not smart enough to drop the libraries that are not
used at all, or so I've been told here before. 

Second side effect: debian packages for libraries end up depending on a
lot of stuff they DON'T depend on. It's the programs that depend on many
libraries, but not the libraries themselves.

> Please change the text to state that shared libraries should include
> dependency information for all the libraries that they depend on, not
> only libc. 

Of course, other (more experienced) developers may go for this... or I may
be wrong about the way the linker works.



				Marcelo


Reply to: