Compiling boost with zlib

2019-01-23 05:28发布

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?

6条回答
倾城 Initia
2楼-- · 2019-01-23 06:08

It took me a while to get Boost to build correctly with zlib support. I blogged about it here.

To sum it up, 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.

查看更多
SAY GOODBYE
3楼-- · 2019-01-23 06:12

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

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-23 06:19

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.

查看更多
对你真心纯属浪费
5楼-- · 2019-01-23 06:28

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.
查看更多
仙女界的扛把子
6楼-- · 2019-01-23 06:29

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

查看更多
虎瘦雄心在
7楼-- · 2019-01-23 06:29

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.

查看更多
登录 后发表回答