diff --git a/configure.in b/configure.in
index effe2ee80e24153a0bc38168c190fe04303e69ab..44e30895f7c8edc51e46b99d8f1aded917ab33af 100644
--- a/configure.in
+++ b/configure.in
@@ -482,9 +482,11 @@ AC_CHECK_LIB(gmp, mpz_fdiv_qr, HaveLibGmp=YES, HaveLibGmp=NO)
 AC_SUBST(HaveLibGmp)
 
 #
-dnl ** check whether this machine has BFD installed (used for debugging)
+dnl ** check whether this machine has BFD and liberty installed (used for debugging)
+dnl ** the order of these tests matters: bfd needs liberty
 #
-AC_CHECK_LIB(bfd, bfd_init)
+AC_CHECK_LIB(iberty, xmalloc)
+AC_CHECK_LIB(bfd,    bfd_init)
 
 #
 # Misc