Bug 722080 - Use -ldl is not portable

Some systems do not have libdl, and functions such as dlsym() may already exist
in libc. We should check whether it is required to link to libdl, or it will
cause error on systems which does not have libdl.