autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

checking for header/library mismatch, rpath problem?


From: Adam Mercer
Subject: checking for header/library mismatch, rpath problem?
Date: Tue, 15 Jun 2010 15:11:58 -0500

Hi

One of the projects I work on is a series of different libraries and
we kept running into problems with users polluting their environments
so during the build process the headers and libraries from
dependencies do not match, i.e. the environment points to headers in
/path/master/include and libraries in /path/old_version/libraries. As
expected this can cause strange build or link errors that take a while
to track down.

To try and ensure that the headers and libraries match I added a check
based on the one used by OpenSSH:

# Sanity check OpenSSL headers
AC_MSG_CHECKING([whether OpenSSL's headers match the library])
AC_RUN_IFELSE(
        [AC_LANG_SOURCE([[
#include <string.h>
#include <openssl/opensslv.h>
int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
        ]])],
        [
                AC_MSG_RESULT(yes)
        ],
        [
                AC_MSG_RESULT(no)
                if test "x$openssl_check_nonfatal" = "x"; then
                        AC_MSG_ERROR([Your OpenSSL headers do not match your
library. Check config.log for details.
If you are sure your installation is consistent, you can disable the check
by running "./configure --without-openssl-header-check".
Also see contrib/findssl.sh for help identifying header/library mismatches.
])
                else
                        AC_MSG_WARN([Your OpenSSL headers do not match your
library. Check config.log for details.
Also see contrib/findssl.sh for help identifying header/library mismatches.])
                fi
        ],
        [
                AC_MSG_WARN([cross compiling: not checking])
        ]
)

to check that the headers and libraries are from the same version of
the library, the macro I wrote to do this check is as follows:

AC_DEFUN([LALSUITE_HEADER_LIBRARY_MISMATCH_CHECK],[
AC_MSG_CHECKING([whether $1 headers match the library])
lib_structure=`echo $1 | sed 's/LAL/lal/'`VCSInfo
header_structure=`echo $1 | sed 's/LAL/lal/'`HeaderVCSInfo
AC_RUN_IFELSE(
  [AC_LANG_SOURCE([[
#include <string.h>
#include <stdlib.h>
#include <lal/$1VCSInfo.h>
int main(void) { exit(XLALVCSInfoCompare(&$lib_structure,
&$header_structure) ? 1 : 0); }
  ]])],
  [
    AC_MSG_RESULT(yes)
  ],
  [
    AC_MSG_RESULT(no)
    AC_MSG_ERROR([Your $1 headers do not match your
library. Check config.log for details.
])
  ],
  [
    AC_MSG_WARN([cross compiling: not checking])
  ]
)
])

This works fine, however there is a problem with this for some of our
users. They prefer not to set LD_LIBRARY_PATH (and friends) and use
the rpath embedded in the linked binary to find the appropriate
libraries. Some of the libraries that we have these checks have
dependent libraries that it seems that the rpaths and not embedded in
the test code created by AC_RUN_IFELSE, so the check fails. On
checking config.log the reason for the failure it is due to the
linking being unable to find the dependent libraries.

Is there a way that the rpaths can be embedded into the test code, or
is there a way that I can rework this test to support these users?

Cheers

Adam



reply via email to

[Prev in Thread] Current Thread [Next in Thread]