[pcre-dev] Bug: Checking for libbz2 under Win32

Page principale
Supprimer ce message
Auteur: Daniel Rodriguez
Date:  
À: pcre-dev
Sujet: [pcre-dev] Bug: Checking for libbz2 under Win32
PCRE Version: 8.00
Environment: Win XP SP3
Sub-Environment: Msys 1.0.11
Compiler: Mingw32

Problem description:

- libbz2 uses the Pascal calling convention (WINAPI) for the functions
under Win32
- The standard autoconf AC_CHECK_LIB fails to include "bzlib.h",
therefore missing the function definition
- The compiler thus, generates a "C" signature for the test function
- The linker fails to find the "C" function
- PCRE will fail to configure if asked to do so against libbz2

Solution:

- Replace the AC_CHECK_LIB test with a custom test (see below)

Original code in configure.ac:

- AC_CHECK_LIB([bz2], [BZ2_bzopen], [HAVE_LIBBZ2=1])

New Code:

AC_MSG_CHECKING([for libbz2])
OLD_LIBS="$LIBS"
LIBS="$LIBS -lbz2"
AC_LINK_IFELSE( AC_LANG_PROGRAM([[
#ifdef HAVE_BZLIB_H
#include <bzlib.h>
#endif]],
[[return (int)BZ2_bzopen("conftest", "rb");]]),
[AC_MSG_RESULT([yes]);HAVE_LIBBZ2=1; break;],
AC_MSG_RESULT([no]))
LIBS="$OLD_LIBS"

Best regards