How to build boost with zlib support?
Asked Answered
S

1

8

I'm trying to build Boost C++ libraries version 1.65.1 on Windows with zlib support. I'm using zlib library from Conan package with zlib which I built previously. I'm trying to understand the right steps for building boost with zlib support to use them for creating Conan recipe for boost. I tried to follow the instructions from the official boost documentation. I set the environment variables ZLIB_LIBRARY_PATH, ZLIB_NAME, and ZLIB_INCLUDE the following way:

set ZLIB_LIBRARY_PATH=C:\Users\ivan.bobev\.conan\data\zlib\1.2.11\igsoft\stable\package\63da998e3642b50bee33f4449826b2d623661505\lib
set ZLIB_NAME=zlibstat
set ZLIB_INCLUDE=C:\Users\ivan.bobev\.conan\data\zlib\1.2.11\igsoft\stable\package\63da998e3642b50bee33f4449826b2d623661505\include

and the build command is:

.\b2.exe -j8 --prefix="C:\work\test_builds\boost\install\x64_shared_release" --build-dir="C:\work\test_builds\boost\build\x64_shared_release" --layout=system architecture=x86 address-model=64 toolset=msvc variant=release debug-symbols=on link=shared threading=multi runtime-link=shared install

The result was:

 - zlib                     : no  (cached)

I also tried to clear boost build cash between runs.

After this I tried to set the environment variables directly from the b2 build command:

.\b2.exe -j8 -sZLIB_LIBRARY_PATH="C:\Users\ivan.bobev\.conan\data\zlib\1.2.11\igsoft\stable\package\63da998e3642b50bee33f4449826b2d623661505\lib"-sZLIB_NAME="zlibstat" -sZLIB_INCLUDE="C:\Users\ivan.bobev\.conan\data\zlib\1.2.11\igsoft\stable\package\63da998e3642b50bee33f4449826b2d623661505\include" --prefix="C:\work\test_builds\boost\install\x64_shared_release" --build-dir="C:\work\test_builds\boost\build\x64_shared_release" --layout=system architecture=x86 address-model=64 toolset=msvc variant=release debug-symbols=on link=shared threading=multi runtime-link=shared install

The result was the same.

Finally I tried adding the options into project-config.jam file the following way:

using zlib : 1.2.11 : <search>C:\Users\ivan.bobev\.conan\data\zlib\1.2.11\igsoft\stable\package\63da998e3642b50bee33f4449826b2d623661505\lib <name>zlibstat <include>C:\Users\ivan.bobev\.conan\data\zlib\1.2.11\igsoft\stable\package\63da998e3642b50bee33f4449826b2d623661505\include ;

Again I have no success.

In the zlib include folder there is subfolder zlib. I also tried the 3 variants from above setting the path as "../include/zlib". No success again.

How to build Boost with zlib support using my pre-built Conan package with zlib?

Shote answered 15/9, 2017 at 13:0 Comment(9)
Who maintains the boost conan package? Most likely you should directly ask them whether zlib support is a feature (or check docs)Wenonawenonah
@seha I'm trying to create my own Conan package with Boost. In the official Boost Conan package GitHub repository there is open issue because currently the support for zlib is not implemented properly.Shote
Okay. So really what you want is to know how to build boost with zlib from your system. That has nothing to do with Conan (except you happened to have installed/built zlib from the conan package)Wenonawenonah
Yes. I will remove Conan tag from the question.Shote
Is the library you get from Conan actually named zlibstat?Norway
@Norway I'm using my Conan recipe for the zlib library and this is the name which I use and which is in the corresponding ZLIB_LIBRARY_PATH directory.Shote
It seems that patching the project-config.jam and injecting the paths to the dependencies works. Take a look to the modified recipe for 1.64.0: github.com/lasote/conan-boost/blob/testing/1.64.0/conanfile.py And let me know if it works. (Method: patch_project_jam)Fragmental
With the project-config.jam It seems to work on Linux/OSX but not in Windows where zlib keeps deactivated. In Linux/OSX the include dir passed to the compiler looks good. (pointing to the zlib/bzip2 packages). I assume you are trying with Windows. Right?Fragmental
@Fragmental Yes, I'm trying it with Windows. I will try the solution in your answer.Shote
F
3

The project-config.jam patch is ok, and actually, is working in Linux and OSX. In Windows you need to replace the "\" characters (escape char in jam language) with "/".

You can see my updated Conan recipe for Boost 1.64.0 here

Fragmental answered 16/9, 2017 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.