Question

Is there is good tutorial on how to compile boost with zlib on windows. I looked over boost reference, but it's vague and not enough. I did download zlib dll and source code and made reference in visual studio. I have link error on

gzip_decompressor();

complete code:

using namespace boost::iostreams;
using namespace std;
std::ifstream file("hello.gz", std::ios_base::in | std::ios_base::binary);
filtering_streambuf < input > in;
in.push(gzip_decompressor());
in.push(file);
boost::iostreams::copy(in, std::cout);

I am getting this error,

Error 11 error LNK2019: unresolved external symbol "_declspec(dllimport) public: __thiscall boost::iostreams::detail::gzip_header::~gzip_header(void)" (__imp??1gzip_header@detail@iostreams@boost@@QAE@XZ) referenced in function "public: __thiscall boost::iostreams::basic_gzip_decompressor \>::~basic_gzip_decompressor >(void)" (??1?$basic_gzip_decompressor@V?$allocator@D@std@@@iostreams@boost@@QAE@XZ) –

Was it helpful?

Solution

The linker actually tells you that it cannot find the "basic_gzip_decompressor". The reason is because you have zlib not built into your boost libraries.

(This SO question claims to have a solution without having to build zlib into boost libs)

I agree that the documentation on this is a bit terse, but it is found here. If your normal build commandline is like this:

b2 -j15 --toolset=msvc --build-type=complete stage 

add the ZLIB definitions to make it build with zlib

b2 -j15 --toolset=msvc --build-type=complete stage -s ZLIB_SOURCE="C:\zlib-1.2.8" -s ZLIB_INCLUDE="C:\zlib-1.2.8" 

you can relatively quickly check whether it works (before compilation is complete) when you look for the configuration check output. There it should say something like:

- zlib               : yes  (cached)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top