Limit the libraries pulled in when dynamic linking.

See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=745543