[boost] [iostreams][gzip][zlib] zlib vs gzip, and linking against external libraries

182 views
Skip to first unread message

Aaron Levy

unread,
Jan 17, 2015, 3:07:25 PM1/17/15
to bo...@lists.boost.org
What is the difference in functionality between gzip and zlib compression?

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?

For reference, this is the command line I used to build the iostreams library.

./b2 --with-iostreams --build-dir=../build threading=multi variant=release link=shared runtime-link=shared

--
Aaron Levy
aaron...@yandex.com

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Arindam Mukherjee

unread,
Jan 17, 2015, 3:29:26 PM1/17/15
to bo...@lists.boost.org
> What is the difference in functionality between gzip and zlib compression?
>
I think gzip and zlib are two different variants of the DEFLATE
algorithm and they differ in their header information.

> 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?
>
> For reference, this is the command line I used to build the iostreams library.
>
> ./b2 --with-iostreams --build-dir=../build threading=multi variant=release link=shared runtime-link=shared
>

The following page lists build settings for iostreams.
http://www.boost.org/doc/libs/1_57_0/libs/iostreams/doc/installation.html

Gives me the impression that you can build against source or against
pre-built libraries for zlib / bzip2. I guess if you built against
source, then you don't need to separately link against zlib / bzip2
libraries.

Arindam

Petr Machata

unread,
Jan 18, 2015, 5:53:16 PM1/18/15
to Aaron Levy, bo...@lists.boost.org
Aaron Levy <aaron...@yandex.com> 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
Reply all
Reply to author
Forward
0 new messages