Don't assume dlsym exists on linux
After checking if -ldl exists, use it for checking for the dlsym function.
This fixes building in environments where the dlsym function is unavailable. (My testcase is NDK builds with -static, where dlsym isn't available for static linking, only if linking dynamically.)