| 1 |
|
| 2 |
Compress-Raw-Zlib |
| 3 |
|
| 4 |
Version 2.222 |
| 5 |
|
| 6 |
8 March 2026 |
| 7 |
|
| 8 |
Copyright (c) 2005-2026 Paul Marquess. All rights reserved. |
| 9 |
This program is free software; you can redistribute it |
| 10 |
and/or modify it under the same terms as Perl itself. |
| 11 |
|
| 12 |
The directory zlib-src contains a subset of the |
| 13 |
source files copied directly from zlib version 1.3.2. |
| 14 |
These files are Copyright(C) 1995-2026 |
| 15 |
Jean-loup Gailly and Mark Adler. |
| 16 |
Full source for the zlib library is available at |
| 17 |
http://www.zlib.org |
| 18 |
|
| 19 |
DESCRIPTION |
| 20 |
----------- |
| 21 |
|
| 22 |
This module provides a Perl interface to the zlib and zlib-ng compression libraries. |
| 23 |
|
| 24 |
PREREQUISITES |
| 25 |
------------- |
| 26 |
|
| 27 |
Before you can build Compress-Raw-Zlib you need to have the following |
| 28 |
installed on your system: |
| 29 |
|
| 30 |
* A C compiler |
| 31 |
|
| 32 |
* Perl 5.006 or better. |
| 33 |
|
| 34 |
By default, Compress-Raw-Zlib will build its own private copy of the |
| 35 |
zlib library. If you want to use a different version of |
| 36 |
zlib or use the zlib-ng library, follow the instructions in the section called |
| 37 |
"Controlling the version of zlib/zlib-ng used by Compress-Raw-Zlib" |
| 38 |
later in this document. |
| 39 |
|
| 40 |
BUILDING THE MODULE |
| 41 |
------------------- |
| 42 |
|
| 43 |
Assuming you have met all the prerequisites, the module can now be built |
| 44 |
using this sequence of commands: |
| 45 |
|
| 46 |
perl Makefile.PL |
| 47 |
make |
| 48 |
make test |
| 49 |
|
| 50 |
INSTALLATION |
| 51 |
------------ |
| 52 |
|
| 53 |
To install Compress-Raw-Zlib, run the command below: |
| 54 |
|
| 55 |
make install |
| 56 |
|
| 57 |
Controlling the version of zlib/zlib-ng used by Compress-Raw-Zlib |
| 58 |
-------------------------------------------------------------------- |
| 59 |
|
| 60 |
Compress-Raw-Zlib interfaces to the zlib or zlib-ng compression libraries. |
| 61 |
There are a number of options available to control which version/instance of |
| 62 |
the zlib/zlib-ng library is used: |
| 63 |
|
| 64 |
1. Build a private copy of the zlib library using the |
| 65 |
zlib library source that is included with this module. |
| 66 |
This is the default option. |
| 67 |
|
| 68 |
2. Build a private copy of the zlib library using a standard |
| 69 |
zlib source distribution. |
| 70 |
This option is not supported with zlib-ng. |
| 71 |
|
| 72 |
3. Use a pre-built zlib or zlib-ng library. |
| 73 |
|
| 74 |
If you intend to use the zlib library with either Option 2 or 3, |
| 75 |
you need to have zlib version 1.2.0 or better. |
| 76 |
Any version of zlib-ng is acceptable. |
| 77 |
|
| 78 |
The configuration for this module is controlled by a series of variable/value pairs. |
| 79 |
These can either be set as environment variables or stored in the file config.in. |
| 80 |
The environment variables will silently take presedence if both are present. |
| 81 |
|
| 82 |
Make sure you have set the environment variables or updated config.in |
| 83 |
before running |
| 84 |
|
| 85 |
perl Makefile.PL |
| 86 |
|
| 87 |
Option 1 |
| 88 |
-------- |
| 89 |
|
| 90 |
For option 1, set the configuration variable/value pairs as follows: |
| 91 |
|
| 92 |
BUILD_ZLIB=True |
| 93 |
ZLIB_INCLUDE=./zlib-src |
| 94 |
ZLIB_LIB=./zlib-src |
| 95 |
OLD_ZLIB=False |
| 96 |
GZIP_OS_CODE=AUTO_DETECT |
| 97 |
USE_ZLIB_NG=False |
| 98 |
|
| 99 |
Option 2 |
| 100 |
-------- |
| 101 |
|
| 102 |
For option 2, fetch a copy of the zlib source distribution from |
| 103 |
http://www.zlib.org and unpack it into the Compress-Raw-Zlib source |
| 104 |
directory. Assuming you have fetched zlib 1.3.2, |
| 105 |
it will create a directory called zlib-1.3.2. |
| 106 |
|
| 107 |
Now set the configuration variables as follows (if the version you have |
| 108 |
fetched isn't 1.3.2, change the ZLIB_INCLUDE and ZLIB_LIB |
| 109 |
variables appropriately): |
| 110 |
|
| 111 |
BUILD_ZLIB=True |
| 112 |
ZLIB_INCLUDE=./zlib-1.3.2 |
| 113 |
ZLIB_LIB=./zlib-1.3.2 |
| 114 |
OLD_ZLIB=False |
| 115 |
GZIP_OS_CODE=AUTO_DETECT |
| 116 |
USE_ZLIB_NG=False |
| 117 |
|
| 118 |
Option 3a - Using zlib |
| 119 |
---------------------- |
| 120 |
|
| 121 |
For this option you need to find out where the zlib files are stored |
| 122 |
on your system. There are two parts to this. |
| 123 |
|
| 124 |
First, find the directory where the zlib library is stored (a |
| 125 |
common name for the the zlib library is libz.so on Unix/Linux derived systems). |
| 126 |
Set the ZLIB_LIB configuration variable to that directory. |
| 127 |
|
| 128 |
Secondly, find the directory where the file zlib.h is stored. Now set |
| 129 |
the ZLIB_INCLUDE configuration variable to that directory. |
| 130 |
|
| 131 |
Next set both the BUILD_ZLIB and USE_ZLIB_NG variables to False. |
| 132 |
|
| 133 |
Finally, if you are running zlib 1.0.5 or older, set the OLD_ZLIB |
| 134 |
variable to True. Otherwise set it to False. |
| 135 |
|
| 136 |
As an example, if the zlib library on your system is in |
| 137 |
/usr/local/lib, zlib.h is in /usr/local/include and zlib is more |
| 138 |
recent than version 1.0.5, the configuration variables should be set as |
| 139 |
follows: |
| 140 |
|
| 141 |
BUILD_ZLIB=False |
| 142 |
ZLIB_INCLUDE=/usr/local/include |
| 143 |
ZLIB_LIB=/usr/local/lib |
| 144 |
OLD_ZLIB=False |
| 145 |
GZIP_OS_CODE=AUTO_DETECT |
| 146 |
USE_ZLIB_NG=False |
| 147 |
|
| 148 |
Option 3b - Using zlib-ng |
| 149 |
------------------------- |
| 150 |
|
| 151 |
For this option you need to find out where the zlib-ng files are stored |
| 152 |
on your system. There are two parts to this. |
| 153 |
|
| 154 |
First, find the directory where the zlib-ng library is stored (some |
| 155 |
common names for the the zlib-ng library are libz-ng.so on Unix/Linux derived systems). |
| 156 |
Set the ZLIB_LIB configuration variable that directory. |
| 157 |
|
| 158 |
Secondly, find the directory where the file zlib-ng.h is stored. Now set |
| 159 |
the ZLIB_INCLUDE configuration variable that directory. |
| 160 |
|
| 161 |
Next set both BUILD_ZLIB and OLD_ZLIB variables to False. |
| 162 |
Set USE_ZLIB_NG to True. |
| 163 |
|
| 164 |
As an example, if the zlib-ng library on your system is in |
| 165 |
/usr/local/lib and zlib-ng.h is in /usr/local/include, the configuration |
| 166 |
variables should be set as follows: |
| 167 |
|
| 168 |
BUILD_ZLIB=False |
| 169 |
ZLIB_INCLUDE=/usr/local/include |
| 170 |
ZLIB_LIB=/usr/local/lib |
| 171 |
OLD_ZLIB=False |
| 172 |
GZIP_OS_CODE=AUTO_DETECT |
| 173 |
USE_ZLIB_NG=True |
| 174 |
|
| 175 |
Setting the Gzip OS Code |
| 176 |
------------------------ |
| 177 |
|
| 178 |
Every gzip stream stores a byte in its header to identify the Operating |
| 179 |
System that was used to create the gzip stream. When you build Compress-Raw-Zlib it will attempt to determine the value that is correct for |
| 180 |
your Operating System. This will then be used by IO::Compress::Gzip as the |
| 181 |
default value for the OS byte in all gzip headers it creates. |
| 182 |
|
| 183 |
The configuration variable GZIP_OS_CODE controls the setting of |
| 184 |
this value when building Compress-Raw-Zlib. If GZIP_OS_CODE is set to |
| 185 |
AUTO_DETECT, Compress-Raw-Zlib will attempt to determine the correct value for |
| 186 |
your Operating System. |
| 187 |
|
| 188 |
Alternatively, you can override auto-detection of the default OS code and |
| 189 |
explicitly set it yourself. Set the GZIP_OS_CODE configuration variable to |
| 190 |
a number between 0 and 255. For example |
| 191 |
|
| 192 |
GZIP_OS_CODE=3 |
| 193 |
|
| 194 |
See RFC 1952 for valid OS codes that can be used. |
| 195 |
|
| 196 |
If you are running one of the less popular Operating Systems, it is |
| 197 |
possible that the default value picked by this module is incorrect or the |
| 198 |
default value (3) is used when there is a better value available. When |
| 199 |
Compress-Raw-Zlib cannot determine what operating system you are running, it |
| 200 |
will use the default value 3 for the OS code. |
| 201 |
|
| 202 |
If you find you have to change this value, because you think the value auto |
| 203 |
detected is incorrect, please take a few moments to contact the author of |
| 204 |
this module. |
| 205 |
|
| 206 |
TROUBLESHOOTING |
| 207 |
--------------- |
| 208 |
|
| 209 |
Undefined Symbol gzsetparams |
| 210 |
---------------------------- |
| 211 |
|
| 212 |
If you get the error shown below when you run the Compress-Raw-Zlib test |
| 213 |
harness it probably means you are running a copy of zlib that is |
| 214 |
version 1.0.5 or older. |
| 215 |
|
| 216 |
t/01version.........Can't load 'blib/arch/auto/Compress/Zlib/Zlib.so' for |
| 217 |
module Compress::Raw::Zlib: blib/arch/auto/Compress/Raw/Zlib/Zlib.so: |
| 218 |
undefined symbol: gzsetparams at ... |
| 219 |
|
| 220 |
There are two ways to fix this problem: |
| 221 |
|
| 222 |
1. Upgrade to the latest version of zlib. |
| 223 |
|
| 224 |
2. Set the configuration variable OLD_ZLIB to True and rebuild. |
| 225 |
|
| 226 |
Test Harness 01version fails |
| 227 |
---------------------------- |
| 228 |
If the 01version test harness fails, and the problem isn't covered by the |
| 229 |
scenario above, it probably means that you have two versions of |
| 230 |
zlib installed on your system. |
| 231 |
|
| 232 |
Run the command below to see if this is indeed the case |
| 233 |
|
| 234 |
make test TEST_VERBOSE=1 TEST_FILES=t/01version.t |
| 235 |
|
| 236 |
Try removing the one you don't want to use and rebuild. |
| 237 |
|
| 238 |
Solaris build fails with "language optional software package not installed" |
| 239 |
--------------------------------------------------------------------------- |
| 240 |
|
| 241 |
If you are trying to build this module under Solaris and you get an |
| 242 |
error message like this |
| 243 |
|
| 244 |
/usr/ucb/cc: language optional software package not installed |
| 245 |
|
| 246 |
it means that Perl cannot find the C compiler on your system. The cryptic |
| 247 |
message is just Sun's way of telling you that you haven't bought their |
| 248 |
C compiler. |
| 249 |
|
| 250 |
When you build a Perl module that needs a C compiler, the Perl build |
| 251 |
system tries to use the same C compiler that was used to build perl |
| 252 |
itself. In this case your Perl binary was built with a C compiler that |
| 253 |
lived in /usr/ucb. |
| 254 |
|
| 255 |
To continue with building this module, you need to get a C compiler, |
| 256 |
or tell Perl where your C compiler is, if you already have one. |
| 257 |
|
| 258 |
Assuming you have now got a C compiler, what you do next will be dependent |
| 259 |
on what C compiler you have installed. If you have just installed Sun's |
| 260 |
C compiler, you shouldn't have to do anything. Just try rebuilding |
| 261 |
this module. |
| 262 |
|
| 263 |
If you have installed another C compiler, say gcc, you have to tell perl |
| 264 |
how to use it instead of /usr/ucb/cc. |
| 265 |
|
| 266 |
This set of options seems to work if you want to use gcc. Your mileage |
| 267 |
may vary. |
| 268 |
|
| 269 |
perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" " |
| 270 |
make test |
| 271 |
|
| 272 |
If that doesn't work for you, it's time to make changes to the Makefile |
| 273 |
by hand. Good luck! |
| 274 |
|
| 275 |
Solaris build fails with "gcc: unrecognized option `-KPIC'" |
| 276 |
----------------------------------------------------------- |
| 277 |
|
| 278 |
You are running Solaris and you get an error like this when you try to |
| 279 |
build this Perl module |
| 280 |
|
| 281 |
gcc: unrecognized option `-KPIC' |
| 282 |
|
| 283 |
This symptom usually means that you are using a Perl binary that has been |
| 284 |
built with the Sun C compiler, but you are using gcc to build this module. |
| 285 |
|
| 286 |
When Perl builds modules that need a C compiler, it will attempt to use |
| 287 |
the same C compiler and command line options that was used to build perl |
| 288 |
itself. In this case "-KPIC" is a valid option for the Sun C compiler, |
| 289 |
but not for gcc. The equivalent option for gcc is "-fPIC". |
| 290 |
|
| 291 |
The solution is either: |
| 292 |
|
| 293 |
1. Build both Perl and this module with the same C compiler, either |
| 294 |
by using the Sun C compiler for both or gcc for both. |
| 295 |
|
| 296 |
2. Try generating the Makefile for this module like this perl |
| 297 |
|
| 298 |
perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" " LD=gcc |
| 299 |
make test |
| 300 |
|
| 301 |
This second option seems to work when mixing a Perl binary built |
| 302 |
with the Sun C compiler and this module built with gcc. Your |
| 303 |
mileage may vary. |
| 304 |
|
| 305 |
HP-UX Notes |
| 306 |
----------- |
| 307 |
|
| 308 |
I've had a report that when building Compress-Raw-Zlib under HP-UX that it |
| 309 |
is necessary to have first built the zlib library with the -fpic |
| 310 |
option. |
| 311 |
|
| 312 |
Linux Notes |
| 313 |
----------- |
| 314 |
|
| 315 |
Although most Linux distributions already come with zlib, some |
| 316 |
people report getting this error when they try to build this module: |
| 317 |
|
| 318 |
$ make |
| 319 |
cp Zlib.pm blib/lib/Compress/Zlib.pm |
| 320 |
AutoSplitting blib/lib/Compress/Zlib.pm (blib/lib/auto/Compress/Zlib) |
| 321 |
/usr/bin/perl -I/usr/lib/perl5/5.6.1/i386-linux -I/usr/lib/perl5/5.6.1 /usr/lib/perl5/5.6.1/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.6.1/ExtUtils/typemap -typemap typemap Zlib.xs > Zlib.xsc && mv Zlib.xsc Zlib.c |
| 322 |
gcc -c -I/usr/local/include -fno-strict-aliasing -I/usr/local/include -O2 -march=i386 -mcpu=i686 -DVERSION=\"1.16\" -DXS_VERSION=\"1.16\" -fPIC -I/usr/lib/perl5/5.6.1/i386-linux/CORE Zlib.c |
| 323 |
Zlib.xs:25:19: zlib.h: No such file or directory |
| 324 |
make: *** [Zlib.o] Error 1 |
| 325 |
|
| 326 |
This usually means that you have not installed the development RPM |
| 327 |
for zlib. Check for an RPM that start with "zlib-devel" in your Linux |
| 328 |
distribution. |
| 329 |
|
| 330 |
Win32 Notes |
| 331 |
----------- |
| 332 |
|
| 333 |
If you are running Activestate Perl (from http://www.activestate.com), |
| 334 |
it ships with a pre-compiled version of Compress-Raw-Zlib. To check if a |
| 335 |
newer version of Compress-Raw-Zlib is available run this from the command |
| 336 |
prompt |
| 337 |
|
| 338 |
C:\> ppm verify -upgrade Compress-Raw-Zlib |
| 339 |
|
| 340 |
If you are not running Activestate Perl and you don't have access |
| 341 |
to a C compiler, you will not be able to build and install this module. |
| 342 |
|
| 343 |
Win32 & Cygwin Notes |
| 344 |
-------------------- |
| 345 |
|
| 346 |
It is not possible to install Compress-Raw-Zlib using the CPAN shell. |
| 347 |
This is because the Compress-Raw-Zlib DLL is itself used by the CPAN shell |
| 348 |
and it is impossible to remove a DLL while it is already loaded under |
| 349 |
Windows. |
| 350 |
|
| 351 |
The workaround is to install Compress-Raw-Zlib manually using the |
| 352 |
instructions given at the start of this file. |
| 353 |
|
| 354 |
SUPPORT |
| 355 |
------- |
| 356 |
|
| 357 |
General feedback/questions/bug reports should be sent to |
| 358 |
https://github.com/pmqs/Compress-Raw-Zlib/issues |
| 359 |
|
| 360 |
FEEDBACK |
| 361 |
-------- |
| 362 |
|
| 363 |
How to report a problem with Compress-Raw-Zlib. |
| 364 |
|
| 365 |
To help me help you, I need all of the following information: |
| 366 |
|
| 367 |
1. The Versions of everything relevant. |
| 368 |
This includes: |
| 369 |
|
| 370 |
a. The *complete* output from running this |
| 371 |
|
| 372 |
perl -V |
| 373 |
|
| 374 |
Do not edit the output in any way. |
| 375 |
Note, I want you to run "perl -V" and NOT "perl -v". |
| 376 |
|
| 377 |
If your perl does not understand the "-V" option it is too |
| 378 |
old. This module needs Perl version 5.004 or better. |
| 379 |
|
| 380 |
b. The version of Compress-Raw-Zlib you have. |
| 381 |
If you have successfully installed Compress-Raw-Zlib, this one-liner |
| 382 |
will tell you: |
| 383 |
|
| 384 |
perl -MCompress::Raw::Zlib -e 'print qq[ver $Compress::Raw::Zlib::VERSION\n]' |
| 385 |
|
| 386 |
If you are running windows use this |
| 387 |
|
| 388 |
perl -MCompress::Raw::Zlib -e "print qq[ver $Compress::Raw::Zlib::VERSION\n]" |
| 389 |
|
| 390 |
If you haven't installed Compress-Raw-Zlib then search Compress::Raw::Zlib.pm |
| 391 |
for a line like this: |
| 392 |
|
| 393 |
$VERSION = "2.222" ; |
| 394 |
|
| 395 |
c. The version of zlib you have used. |
| 396 |
If you have successfully installed Compress-Raw-Zlib, this one-liner |
| 397 |
will tell you: |
| 398 |
|
| 399 |
perl -MCompress::Raw::Zlib -e "print q[zlib ver ]. Compress::Raw::Zlib::ZLIB_VERSION.qq[\n]" |
| 400 |
|
| 401 |
If not, look at the beginning of the file zlib.h. |
| 402 |
|
| 403 |
2. If you are having problems building Compress-Raw-Zlib, send me a |
| 404 |
complete log of what happened. Start by unpacking the Compress-Raw-Zlib |
| 405 |
module into a fresh directory and keep a log of all the steps, including |
| 406 |
the setting of configuration environment variables (if applicable). |
| 407 |
|
| 408 |
[edit config.in or set environment variables, if necessary] |
| 409 |
perl Makefile.PL |
| 410 |
make |
| 411 |
make test TEST_VERBOSE=1 |
| 412 |
|
| 413 |
Paul Marquess <[email protected]> |