How to build boost iostreams with gzip and bzip2 support on Windows

15,076

I am no expert, but this worked for me.

Option 1 (straight from source)

  1. Download source files for zlib and for bzip2.

  2. Extract the downloads to directories, move directories to somewhere you like. I had to avoid C:\Program Files (x86)\ as I couldn't get it to work with spaces in the directory name, so I created C:\Sys\ and used that.

  3. Open a command prompt with elevated privileges (run as administrator), go to your boost directory, e.g. C:\Program Files (x86)\boost\boost_1_50_0\ and type b2.exe --with-iostreams -s BZIP2_SOURCE=C:\Sys\bzip2-1.0.6 -s ZLIB_SOURCE=C:\Sys\zlib-1.2.7

  4. Verify that C:\Program Files (x86)\boost\boost_1_50_0\stage\lib contains the wanted files, e.g. libboost_zlib-vc100-*-1_50 and libboost_bzip2-vc100-*-1_50.

Option 2 (build from source first)

  1. As above, download the source files.

  2. Open a Visual Studio Command Prompt with elevated privileges (run as administrator)

  3. Go to C:\Sys\zlib-1.2.7> and type nmake -f win32\Makefile.msc. This will build zlib.

  4. Go to C:\Sys\bzip2-1.0.6> and type nmake -f makefile.msc. This will build gzip2.

  5. The command for boost now becomes b2.exe --with-iostreams -s BZIP2_BINARY=libbz2 -s BZIP2_INCLUDE=C:/Sys/bzip2-1.0.6 -s BZIP2_LIBPATH=C:/Sys/bzip2-1.0.6 -s ZLIB_BINARY=zlib -s ZLIB_INCLUDE=C:/Sys/zlib-1.2.7 -s ZLIB_LIBPATH=C:/Sys/zlib-1.2.7

Share:
15,076
Cookie
Author by

Cookie

Updated on June 27, 2022

Comments

  • Cookie
    Cookie almost 2 years

    How do I build boost's iostreams library with gzip and bzip2 support?

  • Navin
    Navin over 11 years
    Awesome... Exactly what i was looking for.. Thanks mate
  • Tomáš Zato
    Tomáš Zato over 8 years
    This stinks. If I provide invalid zlib path it still builds. Is there a person that used boost without spending several days struggling with it?
  • codekiddy
    codekiddy over 8 years
    if this does not work for you, omit '-s' and instead set environment variable s ie. 'SET ZLIB_INCLUDE="path/to/file' etc... then run b2 that worked for me
  • Kevin Tonon
    Kevin Tonon over 6 years
    You might also need to adjust the toolset and address-model values to match the pre-compiled zlib and bzip2 binaries. See boost.org/build/doc/html/bbv2/reference/…
  • Joshua
    Joshua about 6 years
    I was able to include from a path with a space by using dos 8.3 filename for Program Files: b2.exe --with-iostreams -s ZLIB_SOURCE="C:\Progra~1\boost\zlib-1.2.11" -s NO_BZIP2=1
  • John
    John almost 6 years
    I had to use absolute paths for the source specifiers. Relative paths did not work.
  • Chris
    Chris almost 6 years
    Why is there no way to use CFLAGS and LIBS (i.e., ZLIB_CFLAGS=$(shell pkg-config --cflags zlib.pc))