Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiling boost with zlib

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?

like image 330
cppanda Avatar asked Feb 08 '11 19:02

cppanda


4 Answers

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.

like image 183
ecotax Avatar answered Nov 12 '22 03:11

ecotax


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.

like image 38
Ferruccio Avatar answered Nov 12 '22 02:11

Ferruccio


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

like image 3
Antoni Avatar answered Nov 12 '22 01:11

Antoni


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.

like image 2
tha Avatar answered Nov 12 '22 01:11

tha