From f5a8815492af27ff046cad6fccebba38d46f6bca Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Fri, 28 Mar 2014 19:47:21 +0000 Subject: [PATCH] HADOOP-10450. Build zlib native code bindings in hadoop.dll for Windows. Contributed by Chris Nauroth. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1582868 13f79535-47bb-0310-9956-ffa450edef68 --- BUILDING.txt | 13 +++++++++++++ hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../hadoop-common/src/main/native/native.vcxproj | 6 ++++++ .../apache/hadoop/io/compress/zlib/ZlibCompressor.c | 12 +++++++++++- 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/BUILDING.txt b/BUILDING.txt index 54e6ddd631..0252571860 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -189,6 +189,7 @@ Requirements: * ProtocolBuffer 2.5.0 * Windows SDK or Visual Studio 2010 Professional * Unix command-line tools from GnuWin32 or Cygwin: sh, mkdir, rm, cp, tar, gzip +* zlib headers (if building native code bindings for zlib) * Internet connection for first build (to fetch all Maven and Hadoop dependencies) If using Visual Studio, it must be Visual Studio 2010 Professional (not 2012). @@ -228,6 +229,18 @@ native code is built by enabling the 'native-win' Maven profile. -Pnative-win is enabled by default when building on Windows since the native components are required (not optional) on Windows. +If native code bindings for zlib are required, then the zlib headers must be +deployed on the build machine. Set the ZLIB_HOME environment variable to the +directory containing the headers. + +set ZLIB_HOME=C:\zlib-1.2.7 + +At runtime, zlib1.dll must be accessible on the PATH. Hadoop has been tested +with zlib 1.2.7, built using Visual Studio 2010 out of contrib\vstudio\vc10 in +the zlib 1.2.7 source tree. + +http://www.zlib.net/ + ---------------------------------------------------------------------------------- Building distributions: diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1c47adf9df..0c3d372193 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -469,6 +469,9 @@ Release 2.4.0 - UNRELEASED HADOOP-10449. Fix the javac warnings in the security package. (szetszwo) + HADOOP-10450. Build zlib native code bindings in hadoop.dll for Windows. + (cnauroth) + BREAKDOWN OF HADOOP-10184 SUBTASKS AND RELATED JIRAS HADOOP-10185. FileSystem API for ACLs. (cnauroth) diff --git a/hadoop-common-project/hadoop-common/src/main/native/native.vcxproj b/hadoop-common-project/hadoop-common/src/main/native/native.vcxproj index 91a9db7f1c..0d67e1ee94 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/native.vcxproj +++ b/hadoop-common-project/hadoop-common/src/main/native/native.vcxproj @@ -58,6 +58,7 @@ $(CustomSnappyInclude) true $(SnappyInclude);$(IncludePath) + $(ZLIB_HOME);$(IncludePath) /D HADOOP_SNAPPY_LIBRARY=L\"snappy.dll\" + + @@ -109,6 +112,9 @@ + + + diff --git a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c index 98305c2e71..142f5eb406 100644 --- a/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c +++ b/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c @@ -47,6 +47,7 @@ static int (*dlsym_deflateEnd)(z_streamp); #endif #ifdef WINDOWS +#include "winutils.h" #include typedef int (__cdecl *__dlsym_deflateInit2_) (z_streamp, int, int, int, int, int, const char *, int); typedef int (__cdecl *__dlsym_deflate) (z_streamp, int); @@ -379,7 +380,16 @@ Java_org_apache_hadoop_io_compress_zlib_ZlibCompressor_getLibraryName(JNIEnv *en } } #endif - return (*env)->NewStringUTF(env, HADOOP_ZLIB_LIBRARY); + +#ifdef WINDOWS + LPWSTR filename = NULL; + GetLibraryName(dlsym_deflateInit2_, &filename); + if (filename != NULL) { + return (*env)->NewString(env, filename, (jsize) wcslen(filename)); + } else { + return (*env)->NewStringUTF(env, "Unavailable"); + } +#endif } /**