There are a very few to the source code of zlib-1.2.5 used here. zconf.h includes R's config.h Makefile.in is ours, not zlib's, and allows us to use PIC flags so this can be included in libR.so. As from R 2.12.2, on a Unix-alike we remap all the symbols (not just those remapped by defining Z_PREFIX) to avoid conflict with system versions of zlib (notably 1.2.5) linked into packages' *.so. The known problems are with libxml2 and libggobi, both of which are linked to libz. This is not needed on Windows where the DLL is named Rzlib.dll and symbols are imported from a named DLL. But Rzlib.def is used to confine exports to symbols marked ZEXPORT in zlib.h. From 2.13.0, Z_PREFIX is defined in zconf.h, except on Windows. Visibility does not work on all platforms in gcc >= 3.3. diff -u /Users/ripley/Sources/zlib-1.2.5/zconf.h ./zconf.h --- /Users/ripley/Sources/zlib-1.2.5/zconf.h 2010-04-18 18:58:06.000000000 +0100 +++ ./zconf.h 2011-04-19 18:49:24.000000000 +0100 @@ -8,127 +8,84 @@ #ifndef ZCONF_H #define ZCONF_H +#ifdef HAVE_CONFIG_H +#include +#endif + +/* R change */ +#ifndef WIN32 +#define Z_PREFIX +#endif plus lots of changes to the defines. diff -u /Users/ripley/Sources/zlib-1.2.5/zlib.h ./zlib.h --- /Users/ripley/Sources/zlib-1.2.5/zlib.h 2010-04-20 05:12:48.000000000 +0100 +++ ./zlib.h 2011-04-19 22:18:56.000000000 +0100 @@ -1576,8 +1576,15 @@ # define gzseek gzseek64 # define gztell gztell64 # define gzoffset gzoffset64 +# undef adler32_combine +# undef crc32_combine +# ifdef Z_PREFIX +# define adler32_combine Rz_adler32_combine64 +# define crc32_combine Rz_crc32_combine64 +# else # define adler32_combine adler32_combine64 # define crc32_combine crc32_combine64 +# endif # ifdef _LARGEFILE64_SOURCE ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); diff -u /Users/ripley/Sources/zlib-1.2.5/zutil.h ./zutil.h --- /Users/ripley/Sources/zlib-1.2.5/zutil.h 2010-04-18 20:29:24.000000000 +0100 +++ ./zutil.h 2011-04-19 19:41:57.000000000 +0100 @@ -13,6 +13,10 @@ #ifndef ZUTIL_H #define ZUTIL_H +#ifdef WIN32 +# define NO_VIZ +#endif + #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else