我尝试使用Boost Zlib Filters库但遇到了一些问题。我正在使用代码块和GNU GCC进行编译。这是我用
进行测试的示例代码#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;
ifstream file("hello.z", ios_base::in | ios_base::binary);
filtering_streambuf<input> in;
in.push(zlib_decompressor());
in.push(file);
copy(in, cout);
return 0;
}
在Code Blocks链接器设置中,我链接了z,boost_system,boost_iostreams。
由于某些原因,当我运行代码时,我收到以下错误
terminate called after throwing an instance of 'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::iostreams::zlib_error> >'
what(): zlib error
Process returned -1 (0xFFFFFFFF) execution time : 0.136 s