[Boost.Iostreams] Building iostreams with zlib support
Hi, I'm trying to compile the following example code on Windows XP using MS Visual Studio 2005: -- from http://www.boost.org/libs/iostreams/doc/classes/zlib.html#installation ////////////////////////////// #include <fstream> #include <iostream> #include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/copy.hpp> #include <boost/iostreams/filter/zlib.hpp> int main() { using namespace std; using namespace boost::iostreams; // added this line ifstream file("hello.z", ios_base::in | ios_base::binary); filtering_streambuf<input> in; in.push(zlib_decompressor()); in.push(file); boost::iostreams::copy(in, cout); } //////////////////////////////// So I downloaded the zlib library into the directory C:\Libs\zlib123 plus a prebuilt windows binary into the directory C:\Libs\zlib123\dll32 After reading http://www.boost.org/libs/iostreams/doc/installation.html I tried to add zlib.cpp to my test project, and to add the line #define BOOST_IOSTREAMS_NO_LIB to my source file. I got a bunch of linker errors, e.g. 1>zlib.obj : error LNK2019: unresolved external symbol _crc32 referenced in function "protected: void __thiscall boost::iostreams::detail::zlib_base::after(char const * &,char * &,bool)" (?after@zlib_base@detail@iostreams@boost@@IAEXAAPBDAAPAD_N@Z) 1>C:\Dev\Test\Test\Debug\Test.exe : fatal error LNK1120: 9 unresolved externals. If I delete ' #define BOOST_IOSTREAMS_NO_LIB' I get the following error: 1>LINK : fatal error LNK1104: cannot open file 'libboost_zlib-vc80-mt-gd-1_34_1.lib' Which is a file that doesn't exist. As I understand it I have to rebuild boost.iostreams with zlib support: C:\boost\boost_1_34_1\libs\iostreams\build>bjam "-sNO_COMPRESSION=0" "-sNO_ZLIB=0" "-sZLIB_SOURCE=C:\Libs\zlib123" "-sZLIB_LIBPATH=C:\Libs\zlib123\dll32" "-sZLIB_BINARY=zlibwapi.dll" I tried this and that but to be honest I don't really know what I'm doing and it didn't work. I would like to compile a static library and link my program against it, so that the example code works. It would also be ok to link it against a .dll - I don't really care, I just want to SOMEHOW use it! :) Can somebody give me detailed instructions on how to do that? Andreas
Andreas Profous wrote:
As I understand it I have to rebuild boost.iostreams with zlib support: C:\boost\boost_1_34_1\libs\iostreams\build>bjam "-sNO_COMPRESSION=0" "-sNO_ZLIB=0" "-sZLIB_SOURCE=C:\Libs\zlib123" "-sZLIB_LIBPATH=C:\Libs\zlib123\dll32" "-sZLIB_BINARY=zlibwapi.dll"
I tried this and that but to be honest I don't really know what I'm doing and it didn't work.
When I did it, I found that I ONLY set the zlib path environment variables... zlib_libpath, zlib_source, and zlib_include. In fact, I just set them as explicit environment variables and then called bjam with the correct toolset. I did not do anything with no_zlib or no_compression or zlib_binary (IIRC they caused me problems). You could try that and see if it works for you.
Hi, eg wrote:
Andreas Profous wrote:
As I understand it I have to rebuild boost.iostreams with zlib support: C:\boost\boost_1_34_1\libs\iostreams\build>bjam "-sNO_COMPRESSION=0" "-sNO_ZLIB=0" "-sZLIB_SOURCE=C:\Libs\zlib123" "-sZLIB_LIBPATH=C:\Libs\zlib123\dll32" "-sZLIB_BINARY=zlibwapi.dll"
I tried this and that but to be honest I don't really know what I'm doing and it didn't work.
Same problem with boost 1.35.0. Using the "-sZLIB..." parameters did not work for me, too.
When I did it, I found that I ONLY set the zlib path environment variables... zlib_libpath, zlib_source, and zlib_include. In fact, I just set them as explicit environment variables and then called bjam with the correct toolset.
I did not do anything with no_zlib or no_compression or zlib_binary (IIRC they caused me problems).
Thanks for the hint. I also set the environment variables (in my case ZLIB_LIBPATH, ZLIB_SOURCE, ZLIB_INCLUDE and ZLIB_BINARY), and this worked. Best regards, Lothar
Hi Andreas, I also got stuck when trying to use zlib in iostreams and found the documentation not very helpful. The "Getting started on Microsoft Windows" is a bit "unorganized" and outdated. That was mentioned before in another thread.
As I understand it I have to rebuild boost.iostreams with zlib support: C:\boost\boost_1_34_1\libs\iostreams\build>bjam "-sNO_COMPRESSION=0" "-sNO_ZLIB=0" "-sZLIB_SOURCE=C:\Libs\zlib123" "-sZLIB_LIBPATH=C:\Libs\zlib123\dll32" "-sZLIB_BINARY=zlibwapi.dll"
I tried this and that but to be honest I don't really know what I'm doing and it didn't work.
What worked for me was C:\boost\boost_1_34_1\libs\iostreams\build>bjam "-sNO_ZLIB=0" "-sZLIB_SOURCE=C:\Libs\zlib123" You have to think about the threading and linking options (look for the specific keywords). Then some libs with "lib" prefix (for static linking) and without that prefix (dynamic linking) should be built as well as the corresponding DLLs. When you use dynamic linking, make sure to add BOOST_ALL_DYN_LINK to your defines. You may also have a look at http://www.codeproject.com/KB/tips/Building_boost_libraries.aspx which was helpful for me. Best regards, Rainer
participants (4)
-
Andreas Profous
-
eg
-
Lothar May
-
Rainer Thaden