Don't try to link to libdl on non-Linux systems

This fixes the build on FreeBSD for instance.