C++ 压缩库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1563700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Compression Libraries For C++
提问by Nathan Campos
I was reading about compression in programs and I started to create a new simple project, a zipper (just a zipper, not an unzipper), but I only found zLib, and it's for C. I know that C libraries can be used in C++, but I like to use C++ libraries. Does anyone know a good one to suggest?
我正在阅读程序中的压缩,我开始创建一个新的简单项目,一个拉链(只是一个拉链,而不是一个解压器),但我只找到了 zLib,它是用于 C 的。我知道 C 库可以在 C++ 中使用,但我喜欢使用 C++ 库。有没有人知道一个好的建议?
Best Regards.
此致。
采纳答案by Robert K
Most compression libraries that I know of are written in C for two reasons: one, the general age of good compression algorithms; and two, the high portability (and stability) of C across platforms.
我所知道的大多数压缩库都是用 C 编写的,原因有两个:一是优秀压缩算法的普遍时代;第二,C 跨平台的高可移植性(和稳定性)。
I suggest any of the following. If you want good licenses select one of the top two, otherwise if you're open to using GPL code pick one of the last two.
我建议以下任何一项。如果您想要良好的许可证,请选择前两个中的一个,否则,如果您愿意使用 GPL 代码,请选择后两个中的一个。
回答by Locksfree
You could do this easily using Boost iostream zlib filter
您可以使用Boost iostream zlib 过滤器轻松完成此操作
回答by Robert K
回答by Zifre
I would suggest using zlib. It is designed for C, but it works fine in C++.
我建议使用 zlib。它是为 C 设计的,但它在 C++ 中运行良好。
Using native C++ libraries really only helps when the library is sufficiently big and complex that it can benefit from object oriented design. zlib is relatively simple, and doesn't need object oriented features.
使用本机 C++ 库只有在库足够大和足够复杂以至于它可以从面向对象设计中受益时才真正有用。zlib 比较简单,不需要面向对象的特性。
回答by Joe
Use libzip: http://www.nih.at/libzip/The license is pretty permissive and it does all you need, from C or C++ code.
使用 libzip:http://www.nih.at/libzip/ 许可证非常宽松,它可以满足您的所有需求,来自 C 或 C++ 代码。
回答by user172818
zlib is strongly recommended. It is well written and the interface is fairly clean. I do not see how much a C++ wrapper can simplify APIs. Furthermore, in my view, zlib achieves a good balance between (de)compression speed and file size. Bzip2 is much slower while the compression ratio of LZO and UCL is worse.
强烈推荐使用 zlib。它写得很好,界面也很干净。我看不出 C++ 包装器可以在多大程度上简化 API。此外,在我看来,zlib 在(解)压缩速度和文件大小之间取得了很好的平衡。Bzip2 慢得多,而 LZO 和 UCL 的压缩比更差。
回答by Aleksander Stankiewicz
This what I like (really fast and good compression rate): http://www.quicklz.com/
这是我喜欢的(非常快且压缩率很好):http: //www.quicklz.com/