Seems like latest gcc needs libm and libdl explicitly specified.