I don't think you need to run AC_LINK_IFELSE if AC_CHECK_LIB said it found the library. If you clear LIBS before the AC_CHECK_LIB, then after the check it will contain what you need to link against.