On Nov 24, 2004, Ralf Wildenhues <[EMAIL PROTECTED]> wrote: > On the other hand, on systems without a needed-following linker, it is > necessary to explicitly list all dependent libraries.
It's a bit more complicated than this, actually. Some linkers are smart enough to look for dependencies, but they look for them in different directories than those listed in -L. GNU ld, for example, looks for DT_NEEDED libs in -rpath-link, so unless you pass -rpath-link for the needed libs, linking might pick up an old version of a library that happens to be in say /usr/lib. However, if you link the lib in explicitly with -l, then it finds it in the -L-specified search path. If you build and install libs in multiple dirs, this can get you into a very confusing situation, unless libtool takes care of issuing the corresponding -rpath-link flags. Also, the encoding of dependent libraries is only possible in dynamic libraries, so you have to know with 100% of certainty whether the linker is going to link a library statically or dynamically. This means taking flags such as -Bstatic and -Bdynamic into account, otherwise you may end up refraining from linking in the dependencies of a libtool library because you know the linker will, but then the linker ends up using the static library, and then your assumption falls apart. Personally, I'd rather not attempt to second-guess the linker, and instead use the --as-needed flag newly-added to GNU ld to implement the libtool semantics you suggest, or perhaps even use --as-needed by default whenever it's available. This would require some portability checking on whether dynamic loaders can actually handle inter-library dependencies properly. We can probably assume GNU/Linux dynamic loaders do, but I wouldn't assume the same for other OSs, particularly non-ELF ones. -- Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Red Hat Compiler Engineer [EMAIL PROTECTED], gcc.gnu.org} Free Software Evangelist [EMAIL PROTECTED], gnu.org} _______________________________________________ http://lists.gnu.org/mailman/listinfo/libtool