1
votes

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) –

1
You will have to be more explicit and provide the exact link errors that you are getting. Note that you have to explicitly link with zlib and boost_iostreams, ie add them and the paths to the project settings. (Let me know if this works for you so I can expand it to an answer.)mockinterface
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<class std::allocator<char> >::~basic_gzip_decompressor<class std::allocator<char> >(void)" (??1?$basic_gzip_decompressor@V?$allocator@D@std@@@iostreams@boost@@QAE@XZ)Pritesh Acharya
Looking at your linking error and repeating my first comment - have you in fact added the boost_iostreams library to the linker inputs of your VS project?mockinterface

1 Answers

2
votes

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" 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)