Building with an IDE or Makefile
Building with Boost.Build


Most of Boost.Iostreams can be used simply by including appropriate headers. This is true, for instance, of all the core components including stream, stream_buffer, filtering_stream and filtering_streambuf and of about two thirds of the concrete Filters and Devices. Some components, however, are implemented in .cpp files; in addition, the regular expression filters depend on Boost.Regex, and the compressions filters rely on the third-party libraries zlib ([Gailly]), libbz2 ([Seward]) and liblzma ([Collin]). Note that liblzma refers to the version from xz-utils which is the version available in for example Linux distributions, not the liblzma from the LZMA SDK from 7zip. To obatin zlib and libbz2, see the instructions here and here.

The components which are implemented in .cpp or which rely on external libraries can be built in two ways: by adding the appropriate .cpp files to your IDE project or makefile, or by using Boost.Build.

Building with an IDE or Makefile

The following table shows which headers contain components defined in .cpp files. If your application includes one of these headers, you'll need to add the corresponding .cpp files to you IDE project or makefile, and to define the preprocessor symbol BOOST_IOSTREAMS_NO_LIB. In addition, if the .cpp file depends on an external library, you'll have to build it from the source or link to a pre-built binary.

Header Source File External Library
boost/iostreams/device/file_descriptor.hpp file_descriptor.cpp -
boost/iostreams/device/mapped_file.hpp mapped_file.cpp -
boost/iostreams/filter/bzip2.hpp bzip2.cpp libbz2
boost/iostreams/filter/gzip.hpp gzip.cpp, zlib.cpp zlib
boost/iostreams/filter/regex.hpp - Boost.Regex
boost/iostreams/filter/zlib.hpp zlib.cpp zlib
boost/iostreams/filter/lzma.hpp lzma.cpp liblzma

Building with Boost.Build

To build with Boost.Build, run b2 from the directory libs/iostreams/build, or from the Boost root directory.

If you want to use the compression filters when building iostreams, you have two choices. You can setup the zlib, bzip2 and/or LZMA toolsets in Boost Build in a jamfile, preferably user-config.jam, as documented in Boost.Build. Note that building from source is not supported for LZMA. Alternatively you can let iostreams setup the zlib, bzip2 and/or LZMA toolsets for you using default values. The former is preferred, especially if your zlib and/or bzip2 installations cannot be found by the iostreams setup.

On most UNIX systems, it should not be necessary to setup the zlib, bzip2 and/or lzma toolsets since the zlib, libbz2 and liblzma headers and binaries are already installed in locations where they will be found automatically. On Windows the zlib, bzip2 and/or LZMA binaries need to be in the PATH, else they will not ordinarily be found by default, so it is always a good idea under Windows to setup the zlib, bzip2 and/or LZMA toolsets in your own jamfile.

You can turn off compression filters when building iostreams by passing one of the Boost Build variables in the table below, defined to 1, using the -s option:

Variable Interpretation
NO_COMPRESSION Disable support for compression filters.
NO_BZIP2 Disable support for the bzip2 filters.
NO_ZLIB Disable support for the zlib filters.
NO_LZMA Disable support for the LZMA/xz filters.