Boost logo

Boost :

Subject: Re: [boost] [iostreams][gzip][zlib] zlib vs gzip, and linking against external libraries
From: Petr Machata (pmachata_at_[hidden])
Date: 2015-01-18 17:53:05


Aaron Levy <aaron.levy_at_[hidden]> writes:

> I built Boost iostreams library on Linux after exporting ZLIB_SOURCE
> and BZIP2_SOURCE environment variables. However when I build a sample
> program using gzip / bzip2 with IOStreams, I do not need to link to
> libzlib or libbz2. Is the zlib / bz2 code built into
> libboost_iostreams in this case?

The boost_iostreams DSO depends on these libraries:

$ eu-readelf -a ./lib64/libboost_iostreams.so.1.55.0 | grep NEEDED
  NEEDED Shared library: [libz.so.1]
  NEEDED Shared library: [libbz2.so.1]
[...]

The dependencies in libboost_iostreams are satisfied by its DT_NEEDED
entries.

Only if you used, say, libbz2 directly in your program would you need to
link to libbz2. (Actually, it depends on the program linker. The older
linkers would satisfy undefined symbols in your objects also from the
DT_NEEDED of shared libraries that you spell out on the command line.
Modern linkers only consider the libraries themselves.)

Thanks,
Petr


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk