I’m checking the portability of a shared object (.so) with the LSB AppChecker.
One of the problems it reports is that there is one external library (libm.so.6) that is not being used but is linked against anyways.
How can I prevent GCC from linking to this unneeded library?
EDIT:
The output of the ldd command against my shared object is:
linux-gate.so.1 => (0x009ff000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x003dc000)
libm.so.6 => /lib/libm.so.6 (0x00110000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00137000)
libc.so.6 => /lib/libc.so.6 (0x0021d000)
/lib/ld-linux.so.2 (0x0097f000)
Pass the -Wl,-as-needed argument as part of the linker command line. This will automatically drop any direct library dependencies you’re not actually using symbols from.