提升zlib问题
我在 VS 2010 下的 boost 中遇到 zlib 库的问题。我构建了库,并在 boost/stage/lib 文件夹中生成了适当的 dll/libs。我将 .dll 添加到程序调试文件夹中,并链接到匹配的.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;
}
它可以编译,这意味着问题出在compressedString的in.push和到retString的副本上。我做错了什么吗?我不允许使用这样的字符串吗?
提前致谢
I'm having a problem with the zlib libraries in boost under VS 2010. I built the libraries and the appropriate dlls/libs were generated in the boost/stage/lib folder. I added the .dlls into my programs debug folder and linked in the matching.lib.
But I'm running into problems when I actually try to use the zlib streams. Heres an example:
#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
If I change my code to the following:
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;
}
It compiles, meaning the problem is with the in.push for compressedString and the copy to the retString. Am I doing something wrong? Am I not allowed to use strings like this?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
基本问题似乎是您尝试在字符串类型而不是流类型上使用boost::iostreams::copy()。此外,包含
zlib.hpp
而不是gzip.hpp
可能也没有什么坏处。Try this:
The basic problem seems to be that you're trying to use
boost::iostreams::copy()
on string types rather than stream types. Also, includingzlib.hpp
instead ofgzip.hpp
probably doesn't hurt either.