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

- 19,847
- 9
- 124
- 140

- 12,004
- 13
- 54
- 83
1 Answers
I am no expert, but this worked for me.
Option 1 (straight from source)
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 createdC:\Sys\
and used that.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 typeb2.exe --with-iostreams -s BZIP2_SOURCE=C:\Sys\bzip2-1.0.6 -s ZLIB_SOURCE=C:\Sys\zlib-1.2.7
Verify that
C:\Program Files (x86)\boost\boost_1_50_0\stage\lib
contains the wanted files, e.g.libboost_zlib-vc100-*-1_50
andlibboost_bzip2-vc100-*-1_50
.
Option 2 (build from source first)
As above, download the source files.
Open a
Visual Studio Command Prompt
with elevated privileges (run as administrator)Go to
C:\Sys\zlib-1.2.7>
and typenmake -f win32\Makefile.msc
. This will buildzlib
.Go to
C:\Sys\bzip2-1.0.6>
and typenmake -f makefile.msc
. This will buildgzip2
.The command for
boost
now becomesb2.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

- 12,004
- 13
- 54
- 83
-
7This stinks. If I provide invalid zlib path it still builds. Is there a person that used boost without spending several days struggling with it? – Tomáš Zato Sep 21 '15 at 12:01
-
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 – codekiddy Nov 22 '15 at 13:20
-
You might also need to adjust the toolset and address-model values to match the pre-compiled zlib and bzip2 binaries. See http://www.boost.org/build/doc/html/bbv2/reference/tools.html#bbv2.reference.tools.compilers – Kevin Tonon Jan 11 '18 at 14:47
-
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 – Joshua Apr 04 '18 at 15:01
-
I had to use absolute paths for the source specifiers. Relative paths did not work. – John Jun 14 '18 at 14:19
-
Why is there no way to use CFLAGS and LIBS (i.e., `ZLIB_CFLAGS=$(shell pkg-config --cflags zlib.pc)`) – Chris Jun 19 '18 at 18:33