From ad22e8420fb2f4fa1d98a3753ac844c3dd27d8ce Mon Sep 17 00:00:00 2001 From: "Hoang M. Le" Date: Wed, 21 Dec 2016 21:51:26 +0100 Subject: Fix two issues with AC_LINK_IFELSE for metaSMT: 1. It expects only 2 arguments, so if linking succeeds, nothing will happen (thanks to []), otherwise the message "checking for new_bitvector() in -lmetaSMT" will appear. The latter is that what we currently observe, which means linking actually failed. 2. The reason for linking failure is the use of "-lmetaSMT" in LDFLAGS. AC_LINK_IFELSE does approximately the following: ${CXX} ... -lmetaSMT ${EXECUTABLE_NAME} ${LIBS}, which causes "libmetaSMT cannot be found" (at least on Ubuntu Xenial, where ${LIBS} = -lz). After consulting https://www.gnu.org/software/autoconf/manual/autoconf-2.66/html_node/Running-the-Linker.html, adding "-lmetaSMT" to ${LIBS} seems to be the correct solution. --- autoconf/configure.ac | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'autoconf') diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 4da750cb..e732ffc4 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -803,16 +803,23 @@ else dnl AC_LANG(C++) old_CPPFLAGS="$CPPFLAGS" old_LDFLAGS="$LDFLAGS" + old_LIBS="$LIBS" CPPFLAGS="$CPPFLAGS -I$metasmt_root/include" - LDFLAGS="$LDFLAGS -L$metasmt_root/lib -lmetaSMT" + LDFLAGS="$LDFLAGS -L$metasmt_root/lib" + LIBS="$LIBS -lmetaSMT" + AC_CHECK_HEADERS([$metasmt_root/include/metaSMT/DirectSolver_Context.hpp $metasmt_root/include/metaSMT/frontend/QF_BV.hpp],, [ AC_MSG_ERROR([Unable to use $metasmt_root/include/metaSMT/DirectSolver_Context.hpp header]) ]) + AC_MSG_CHECKING([for new_bitvector() in -lmetaSMT]) AC_LINK_IFELSE( - [AC_LANG_PROGRAM([#include $metasmt_root/include/metaSMT/frontend/QF_BV.hpp], [metaSMT::logic::QF_BV::new_bitvector(3)])], - [],[AC_MSG_CHECKING([for new_bitvector() in -lmetaSMT])],[AC_MSG_ERROR([Unable to link with libmetaSMT])]) + [AC_LANG_PROGRAM([#include ], [metaSMT::logic::QF_BV::new_bitvector(3)])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([Unable to link with libmetaSMT])]) CPPFLAGS="$old_CPPFLAGS" LDFLAGS="$old_LDFLAGS" + LIBS="$old_LIBS" AC_DEFINE(ENABLE_METASMT, 1, [Enable metaSMT API]) AC_SUBST(METASMT_ROOT,$metasmt_root) -- cgit 1.4.1