From e61d2f624348329f8d73af55e6ff3e0e7ee012da Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Mon, 26 Jun 2017 21:03:01 -0700 Subject: On UN*X, make sure we can find inflate() in libz. 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 Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- acinclude.m4 | 22 +++++++++++++++++++++- cmake/modules/FindZLIB.cmake | 16 ++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index fcbbab8327..4ab5bcbdfb 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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. diff --git a/cmake/modules/FindZLIB.cmake b/cmake/modules/FindZLIB.cmake index ac4259b984..34fb1bb608 100644 --- a/cmake/modules/FindZLIB.cmake +++ b/cmake/modules/FindZLIB.cmake @@ -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 "") -- cgit v1.2.1