我在 VS 2010 下的 boost 中的 zlib 库有问题。我构建了这些库,并在 boost/stage/lib 文件夹中生成了适当的 dlls/libs。我将 .dll 添加到我的程序调试文件夹中并链接到了matching.lib。
但是当我实际尝试使用 zlib 流时,我遇到了问题。这是一个例子:
#include <cstring>
#include <string>
#include <iostream>
#include <boost\iostreams\filter\gzip.hpp>
#include <boost\iostreams\filtering_streambuf.hpp>
#include <boost\iostreams\copy.hpp>
std::string DecompressString(const std::string &compressedString)
{
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::zlib_decompressor());
in.push(compressedString);
std::string retString = "";
copy(in, retString);
return retString;
}
when I try to compile thise though, I get multiple errors including:
error C2039: 'char_type' : is not a member of 'std::basic_string<_Elem,_Traits,_Ax>' c:\program files (x86)\boost\boost_1_46_0\boost\iostreams\traits.hpp
error C2208: 'boost::type' : no members defined using this type c:\program files (x86)\boost\boost_1_46_0\boost\iostreams\traits.hpp
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\boost\boost_1_46_0\boost\iostreams\traits.hpp
如果我将代码更改为以下内容:
std::string DecompressString(const std::string &compressedString)
{
boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
in.push(boost::iostreams::zlib_decompressor());
std::string retString = "";
return retString;
}
它可以编译,这意味着问题在于压缩字符串的 in.push 和 retString 的副本。难道我做错了什么?我不允许使用这样的字符串吗?
提前致谢