16

I'm compiling boost with bjam under Windows 7 (64bit-should be irrelevant)

D:\development\boost\boost_1_44\libs\iostreams\build>bjam stage ^
--toolset=msvc-10.0 link=static ^
--build-type=complete ^
-s ZLIB_SOURCE=C:\zlib125-dll ^
-s ZLIB_LIBPATH=C:\zlib125-dll\lib ^
-s ZLIB_INCLUDE=C:\zlib125-dll\include ^
-s ZLIB_BINARY=C:\zlib125-dll

But I only get

stage/libboost_iostreams-vc100-mt-gd-1_44.lib
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/msvc-10.0/debug/threading-multi/boost_iostreams-vc100-mt-gd-1_44.lib

bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.dll
bin.v2/libs/iostreams/build/zlib/msvc-10.0/debug/threading-multi/boost_zlib-vc100-mt-gd-1_44.lib

but stage/libboost_zlib-vc100-mt-gd-1_44.lib is missing.

Am I compiling something wrong?

when I try running my project that worked well with boost and self-compiled boost/thread libraries I get the following error when I include the boost zlib stuff

6>LINK : fatal error LNK1104: cannot open file 'libboost_zlib-vc100-mt-gd-1_44.lib'

Does anyone know what I'm doing wrong?

0

8 Answers 8

18

I did manage to build them using the option
-sZLIB_SOURCE="C:\zlib-1.2.5"
Note there is no space after the -s and the quotes around the path.

2
  • 7
    Just to make it clear: You also can't have spaces IN the path. That's very important and, of course, totally undocumented.
    – user673679
    Commented Apr 11, 2013 at 19:12
  • @user673679 Took me two hours to build it because I had spaces in the path. I hate the boost documentation. Thanks for posting this hint.
    – kostrykin
    Commented Feb 25, 2014 at 12:58
5

It took me a while to get Boost to build correctly with zlib support.

The problem I ran into was that at some point zlib no longer included a gzio.c source file. The jamfile for the Boost build system (jamfile.v2) had a reference to the gzio module which caused it fail. The solution was to remove that reference before building.

I'm not sure this answer is relevant any longer, unless you're trying to build an old version of Boost. I believe the original build issue has been fixed in more recent versions of Boost.

2
  • tried it with your scripts parameters, but still no luck. only more iostream versions get compiled, but no zlib static librarys
    – cppanda
    Commented Feb 8, 2011 at 20:46
  • 7
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Commented Mar 5, 2014 at 2:33
3

I had the same problem (Windows 7 Visual Studio) and I believe the issue is not in how you build boost.

1) As ecotax, there should not be a space after the -s 2) When running bjam, add the flag --debug-configuration. If in the output you do not see errors and it prints out something like

notice: iostreams: using prebuilt zlib

then it has found your zlib copy, which it is good.

3) Notice that the library libboost_zlib-vc100-mt-gd-1_44.lib should not be produced.

4) When you compile your application in Visual Studio, seems that Boost.Iostreams auto-linking still wants libboost_zlib-vc100-mt-gd-1_44.lib and reports a link error.

What it worked for me (I founded googling) was to add to the preprocessor definitions the flag

BOOST_IOSTREAMS_NO_LIB

2
  • 2
    It works for me, but after fixing preprocessor definitions, I got these errors. error LNK2001: unresolved external symbol "int const boost::iostreams::zlib::default_compression". Do you have any idea?
    – Joshua Son
    Commented Mar 7, 2014 at 23:37
  • It means that bjam didn't found the path to zlib and iostreams was built w/o zlib support. You have to provide ZLIB_INCLUDE and ZLIB_LIBPATH to the bjam with correct paths with your version of zlib. Commented Dec 2, 2014 at 0:27
3

I was trying all sorts of things and had a hard time finding the correct solution for newer versions of boost (1.75.0).

All the -sZLIB_xxx switches seem to be not working anymore.

Boost Documentation just states

On Windows the zlib, bzip2, zstd 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, zstd and/or LZMA toolsets in your own jamfile.

Setting path did not lead to any success, so I dig through more documentation. Boost provided jam documentation and examples are not the most helpful, so through analysis of the Conan Recipe for the Conan boost package I finally came up with this minimal user-config.jam file that does the trick for me:

using zlib : your.zlib.version :
  <include>"path/to/zlib/include/headers"
  <search>"path/to/zlib/library/file" ;

The minimal b2 command to execute this for me is:

.\b2.exe --user-config="path/to/user-config.jam"

Hope this can be of help to others so they don't need to waste a lot of time as I did.

2

I took a combination of advice from other answers here and this is what I did:

Extract zlib to C:\zlib\zlib-1.2.11.

Use CMake to configure and generate MS Visual Studio 2017 project and use MS Visual Studio 2017 to build the project. I built it in place so that C:\zlib\zlib-1.2.11 now contains (in addition to previous contents) directories lib and include.

Extract Boost 1.67.0 to C:\Boost\boost_1_67_0.

(Be on drive C:)

cd \Boost\boost_1_67_0
bootstrap.bat
set ZLIB_SOURCE="C:\zlib\zlib-1.2.11"
set ZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include"
set ZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"

The following line built libboost_iostreams and it did put libboost_zlib files in C:\Boost\boost_1_67_0\stage\lib:

b2 --debug-configuration --with-iostreams -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"

The following line built the rest of Boost:

b2 -sZLIB_SOURCE="C:\zlib\zlib-1.2.11" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.11\include" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.11\lib"

Don't know if this is the most optimal way to do it, but it did build the libboost_zlib lib files.

1

For guys, who compiling, using prebuilt 'zlib'. These steps needs to be done:

  • Download and build 'zlib'
  • Run b2.exe --with-iostreams -s ZLIB_BINARY=zlib -s ZLIB_INCLUDE=C:/Sys/zlib-1.2.7/Include -s ZLIB_LIBPATH=C:/Sys/zlib-1.2.7/Lib release

Update paths to your local installation zlib folder. This way, Boost will embed into libboost_iostreams the gzip.cpp, zlib.cpp files. No libboost_zlib will be generated.

  • At your source file add this lines (somewhere in stdafx.h, before including Boost.Iostream headers):

--

#ifdef _DEBUG
  #define BOOST_ZLIB_BINARY zlibd
#else
  #define BOOST_ZLIB_BINARY zlib
#endif

This tells that you don't want to link against libboost_zlib, but you provide precompiled zlib library instead.

  • At your project settings provide path to zlib.lib file.
  • It should compile and link now.
1
  • 1
    It will work, but I have a feeling that the correct solution is the following. First do b2.exe --with-iostreams -s ZLIB_INCLUDE=<path-to-zlib> [other options]. I.e., omit the ZLIB_BINARY and ZLIB_LIBPATH switches since they are ignored. Then just link your project with zlib libraries manually. However I'm too lazy to investigate it properly :) Commented Aug 1, 2016 at 22:11
0
  1. Use Cmake to Build Zlib, but build it in place (not in build folder) i.e in Cmake-
 where is the source code - C:\zlib\zlib-1.2.13
 where to build the binaries - C:\zlib\zlib-1.2.13
  1. Make changes to Bootstrap.bat file
set ZLIB_SOURCE="C:\zlib\zlib-1.2.13"
set ZLIB_INCLUDE="C:\zlib\zlib-1.2.13"
set ZLIB_LIBPATH="C:\zlib\zlib-1.2.13"
  1. For building Boost with iostreams run this command-

b2 --with-iostreams -sZLIB_SOURCE="C:\zlib\zlib-1.2.13" -sZLIB_INCLUDE="C:\zlib\zlib-1.2.13" -sZLIB_LIBPATH="C:\zlib\zlib-1.2.13"

  1. For building rest of the Boost Libraries run-

b2

-1

set ZLIB_SOURCE="c:\zlib"

set ZLIB_INCLUDE="c:\zlib"

.\b2

.\bjam will not build but .\b2 will build the library: stage/libboost_zlib-vc100-mt-gd-1_44.lib

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.