On UN*X, make sure we can find inflate() in libz.
authorGuy Harris <guy@alum.mit.edu>
Tue, 27 Jun 2017 04:03:01 +0000 (21:03 -0700)
committerGuy Harris <guy@alum.mit.edu>
Tue, 27 Jun 2017 07:48:58 +0000 (07:48 +0000)
For example, on at least some versions of Fedora, if you have a 64-bit
machine, have both the 32-bit and 64-bit versions of the run-time zlib
package installed, and have only the *32-bit* version of the zlib
development package installed, it'll find the header, and think it can
use zlib, and will use it in subsequent tests, but it'll try and link
64-bit test programs with the 32-bit library, causing those tests to
falsely fail.  Hilarity ensues.

Change-Id: Ic2536e8a652ef96e2a3923c1faa61f6c8c06bf58
Reviewed-on: https://code.wireshark.org/review/22417
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
acinclude.m4
cmake/modules/FindZLIB.cmake

index fcbbab8327981e3b13f750bd4aec623097a2cd52..4ab5bcbdfb89dc4040d6d61941618a421080379f 100644 (file)
@@ -495,17 +495,37 @@ AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
        then
                #
                # Well, we at least have the zlib header file.
+               #
                # We link with zlib to support uncompression of
                # gzipped network traffic, e.g. in an HTTP request
                # or response body.
                #
+               # Check for inflate() in zlib, to make sure the
+               # zlib library is usable.  For example, on at
+               # least some versions of Fedora, if you have a
+               # 64-bit machine, have both the 32-bit and 64-bit
+               # versions of the run-time zlib package installed,
+               # and have only the *32-bit* version of the zlib
+               # development package installed, it'll find the
+               # header, and think it can use zlib, and will use
+               # it in subsequent tests, but it'll try and link
+               # 64-bit test programs with the 32-bit library,
+               # causing those tests to falsely fail.  Hilarity
+               # ensues.
+               #
                if test "x$zlib_dir" != "x"
                then
                  WS_CPPFLAGS="$WS_CPPFLAGS -I$zlib_dir/include"
                  AC_WIRESHARK_ADD_DASH_L(WS_LDFLAGS, $zlib_dir/lib)
                fi
-               LIBS="-lz $LIBS"
                AC_DEFINE(HAVE_ZLIB, 1, [Define to use zlib library])
+               #
+               # Check for "inflate()" in zlib to make sure we can
+               # link with it.
+               #
+               AC_CHECK_LIB(z, inflate,,
+                   AC_MSG_ERROR([zlib.h found but linking with -lz failed to find inflate(); do you have the right developer package installed (32-bit vs. 64-bit)?]))
+
                #
                # Check for "inflatePrime()" in zlib, which we need
                # in order to read compressed capture files.
index ac4259b9847198b50983b7ff4acd04ae401ac30a..34fb1bb608406a9c527ce108a1358f623421cb97 100644 (file)
@@ -102,6 +102,22 @@ IF(WIN32)
 ELSE()
     INCLUDE(CheckFunctionExists)
     SET(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARY})
+    #
+    # Check for inflate() in zlib, to make sure the zlib library is
+    # usable.
+    #
+    # For example, on at least some versions of Fedora, if you have a
+    # 64-bit machine, have both the 32-bit and 64-bit versions of the
+    # run-time zlib package installed, and have only the *32-bit*
+    # version of the zlib development package installed, it'll find the
+    # header, and think it can use zlib, and will use it in subsequent
+    # tests, but it'll try and link 64-bit test programs with the 32-bit
+    # library, causing those tests to falsely fail.  Hilarity ensues.
+    #
+    CHECK_FUNCTION_EXISTS("inflate" HAVE_INFLATE)
+    IF(NOT HAVE_INFLATE)
+        MESSAGE(FATAL_ERROR "zlib.h found but linking with -lz failed to find inflate(); do you have the right developer package installed (32-bit vs. 64-bit)?")
+    ENDIF()
     CHECK_FUNCTION_EXISTS("inflatePrime" HAVE_INFLATEPRIME)
     # reset
     SET(CMAKE_REQUIRED_LIBRARIES "")