On Fri, 2006-06-30 at 09:30 +0200, Ralf Ertzinger wrote: > Hi. > > On Fri, 30 Jun 2006 09:23:20 +0200, Hans de Goede wrote: > > > How about using ld --as-needed, AFAIK that has come up before and > > would be a great improvement! > > In the few cases that I've tried it it simply did not work as adveritsed > (or maybe I misunderstood it's purpose). > > To wit: > > > cat > test.c <<EOF > #include <stdio.h> > > int main(int argc, char** argv) { > > fprintf(stdout, "This is a test\n"); > > return 0; > } > EOF > > > gcc -o test.o -c test.c > > gcc -o test -lxml2 -Wl,--as-needed test.o > > ldd -r -u ./test > Unused direct dependencies: > > /usr/lib/libxml2.so.2 However: $ cat > test.c <<EOF #include <stdio.h> int main(int argc, char** argv) { fprintf(stdout, "This is a test\n"); return 0; } EOF $ gcc -o test.o -c test.c $ gcc -o test -lxml2 -Wl,--as-needed test.o $ ldd -r -u ./test Unused direct dependencies: /usr/lib/libxml2.so.2 $ gcc -o test -Wl,--as-needed -lxml2 test.o $ ldd -r -u ./test (no output) Paul.