Linux From Scratch: Version 5.1-pre1
Prev | Chapter 6. Installing basic system software | Next

# Installing Zlib-1.2.1

The Zlib package contains compression and uncompression routines used by some programs.

    Approximate build time:  0.1 SBU
    Required disk space:     1.5 MB

Official download location for Zlib (1.2.1):
http://www.gzip.org/zlib/

For its installation Zlib depends on: Binutils, Coreutils, GCC, Glibc, Make, Sed.

##

## Installation of Zlib

Prepare Zlib for compilation:

    ./configure --prefix=/usr --shared

> Note: Zlib is known to build its shared library incorrectly if CFLAGS is specified in the environment. If you are using your own CFLAGS variable, be sure to add the -fPIC directive to your CFLAGS for the duration of the above command, then remove it afterwards.

Compile the package:

    make

This package has a test suite available which can perform a number of checks to ensure it built correctly. The test suite for Zlib is quick and painless so we recommend it be run. The following command will test the shared library:

    make check

Install the shared library:

    make install

Now also build the non-shared (static) library:

    make clean
    ./configure --prefix=/usr
    make

The following command will test the static library:

    make check

Install the static library:

    make install

And fix the permissions on the static library:

    chmod 644 /usr/lib/libz.a

It is good policy and common practice to place important libraries into the `/lib` directory. This matters most in scenarios where `/usr` is on a separate partition. Essentially, the run-time components of any libraries depended upon by programs in `/bin` or `/sbin` should reside in `/lib` so that they are on the root partition and available in the event of `/usr` being inaccessible.

Therefore we move the run-time components of the shared Zlib into `/lib` by issuing the following command:

    mv /usr/lib/libz.so.* /lib

Now we need to fix up the `/usr/lib/libz.so` symlink because we just moved the location of the file it points to:

    ln -sf ../../lib/libz.so.1 /usr/lib/libz.so

##

## Contents of Zlib

Installed libraries: libz[a,so]

## Short description

libz* contains compression and uncompression functions used by some programs.

Prev | Home | Next
Installing Coreutils-5.0 | Up | Installing Lfs-Utils-0.4.2