I am currently using Boost.IOStreams to read some compressed data out of a database. When I tried to user a zlib_decompressor object to deflate the incoming stream, it failed to compile. It turns out that you have to add zlib to the boost build process, so I grabbed a copy of the latest zlib sources and made the necessary change to my boost build script (added -sZLIB_SOURCE=… so that boost.build could find the zlib sources).
Unfortunately the build failed. Bjam complained that it was missing a dependency (gzio.c). After a bit of trial and error with various boost.build options, I found the problem. I checked the zlib change log and it turns out that in version 220.127.116.11 they removed the gzio.c file from the zlib sources. Unfortunately, this was a very recent change so boost.build has not yet been updated to reflect the current zlib.
The fix is simple. Look in the boost source tree in the /libs/iostreams/build directory. There is a file named Jamfile.v2. Remove the gzio reference from line 136 so that it reads:
crc32 deflate infback inffast inflate inftrees trees uncompr zutil :
That’s all you need to do. Boost should now build and incorporate zlib into boost.iostreams. I added a command to my boost build script to automatically make this change. It uses the Gnuwin32 sed command:
sed -i s/gzio//g "%BOOST_ROOT%\libs\iostreams\build\jamfile.v2"
Here is my complete build script. It builds Boost for Win32 using statically linked boost libraries and C runtime. It assumes that you have boost_1_42_0.zip and zlib124.zip in the same directory as the build script. It also assumes that you have bjam.exe and the following Gnuwin32 tools in your path: unzip.exe, sed.exe, and grep.exe.
setlocal set BOOST_MAJOR=1 set BOOST_MINOR=42 set BOOST_REV=0 set ZLIB_MAJOR=1 set ZLIB_MINOR=2 set ZLIB_REV=4 set INSTALL=c:\boost set VC_ROOT=%PROGRAMFILES%\Microsoft Visual Studio 9.0\VC set TOOLSET=msvc-9.0 set ZLIB_ROOT=%CD%\zlib-%ZLIB_MAJOR%.%ZLIB_MINOR%.%ZLIB_REV% set PARAM=--without-mpi toolset=%TOOLSET% set PARAM=%PARAM% -sZLIB_SOURCE="%ZLIB_ROOT%" set BOOST_ROOT=%CD%\boost_%BOOST_MAJOR%_%BOOST_MINOR%_%BOOST_REV% set BUILD=%CD%\build set STAGE=%CD%\stage path %CD%;%PATH% if exist "%STAGE%-x86\lib" del /q "%STAGE%-x86\lib\*" if not exist "%ZLIB_ROOT%" unzip zlib*.zip if not exist "%BOOST_ROOT%" unzip boost*.zip sed -i s/gzio//g "%BOOST_ROOT%\libs\iostreams\build\jamfile.v2" pushd "%BOOST_ROOT%" setlocal call "%VC_ROOT%\vcvarsall.bat" x86 set PARAM=%PARAM% variant=debug variant=release link=static runtime-link=static threading=multi bjam %PARAM% --build-dir="%BUILD%-x86" --stagedir="%STAGE%-x86" stage cd "%STAGE%-x86\lib" dir /b | grep -v "\-%BOOST_MAJOR%_%BOOST_MINOR%" | sed "s/^/del /" | cmd if exist "%INSTALL%" rd /s /q "%INSTALL%" xcopy /s /i "%STAGE%-x86\lib" "%INSTALL%\lib-x86" xcopy /s /i "%BOOST_ROOT%\boost" "%INSTALL%\include\boost-%BOOST_MAJOR%_%BOOST_MINOR%\boost" endlocal popd endlocal