boost zlib problem on linux (works fine on windows)
Hello all,
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
AMDG 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
#include #include #include #include using namespace std; int main() { string message = "this is a test message!"; cout << "message: " << message << endl; string compressed; boost::iostreams::filtering_streambufboost::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_streambufboost::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
participants (2)
-
ChristinaDRS
-
Steven Watanabe