|
Boost Users : |
Subject: Re: [Boost-users] boost zlib problem on linux (works fine onwindows)
From: ChristinaDRS (mail_at_[hidden])
Date: 2009-09-22 14:31:58
Hey Steven,
Can you post example code to do this?
I'm very new to boost!
Thanks,
Christina
>>Try calling flush on the streambuf.
>>In Christ,
>>Steven Watanabe
ChristinaDRS wrote:
> This code works fine on Windows, but I get the exception when running in
> linux.. any ideas why? The code, how its compiled, and error are below:
>
> #include <iostream>
> #include <sstream>
> #include <boost/iostreams/copy.hpp>
> #include <boost/iostreams/device/back_inserter.hpp>
> #include <boost/iostreams/filter/bzip2.hpp>
> #include <boost/iostreams/filter/zlib.hpp>
> #include <boost/iostreams/filtering_stream.hpp>
> using namespace std;
>
> int main()
> {
> string message = "this is a test message!";
> cout << "message: " << message << endl;
> string compressed;
> boost::iostreams::filtering_streambuf<boost::iostreams::output>
> out;
> out.push(boost::iostreams::zlib_compressor());
> out.push(boost::iostreams::back_inserter(compressed));
> boost::iostreams::copy(boost::make_iterator_range(message), out);
> cout << "compressed message: " << compressed << endl;
>
> boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
> in.push(boost::iostreams::zlib_decompressor());
> in.push(boost::make_iterator_range(compressed));
> string decompressed;
> boost::iostreams::copy(in,
> boost::iostreams::back_inserter(decompressed));
> cout << "decompressed message: " << decompressed << endl;
> }
>
>
> # g++ zlib.cpp zlib_test2.cpp -o zlib_test2 -lz
> # ./zlib_test2
> message: this is a test message!
> compressed message:
> terminate called after throwing an instance of
> 'boost::iostreams::zlib_error'
> what(): zlib error
> Aborted
> #
>
Try calling flush on the streambuf.
In Christ,
Steven Watanabe
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/Re%3A--Boost-users--boost-zlib-problem-on-linux-%28works-fine-onwindows%29-tp25530861p25530861.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net