How to eliminate unnecessary shared libraries from binary?

From: Dennis (rwlin_at_avamax.com)
Date: 01/31/05


Date: Mon, 31 Jan 2005 12:32:25 +0800

Hello all,

    I have several utilities sharing one makefile with common linking flags.
For example,

            LFLAGS= -lpthread -lm -ljpeg

           (BINPATH)%: %.c
                           $(CC) $(CFLAGS) $(INCLUDE) -o $@ $< -L$(LIBPATH)
$(LFLAGS)

    The executable is always linked with the 3 shared libraries even if they
are not necessary which produces the runtime loading error. Is it possible
for ld smart enough to check the real dependency and linked with them only?

Dennis