如何将 zlib 添加到现有的 qt 安装中

发布于 2024-10-07 21:30:52 字数 58 浏览 8 评论 0原文

如何将 zlib 添加到 Qt 的现有安装中。我对此很陌生,所以请给我详细的描述! 提前感谢您的帮助!

How can I add zlib to an existing installation of Qt. I m pretty new in this so please give me detailed description!
Thanks for your help in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

混吃等死 2024-10-14 21:30:52

zlib 包含在 Qt 核心库中。如果你想在 Qt 程序中使用 zlib 函数,你只需要包含 src/3rdparty/zlib 中的 zlib.h 即可。例如,请参见 src/corelib/tools 中 QByteArray 的实现。

如果您想使用 quazip,只需将库添加到您的项目中即可。它基于 Qt 库。请注意构建与您的 Qt 安装相对应的正确 qyazip 库。

通过将以下行添加到项目文件中,您可以获得正确的包含路径:

INCLUDEPATH += $[QT_INSTALL_PREFIX]/src/3rdparty/zlib

对于 Qt5,请参阅 Thorbjørn 的评论:使用 #include 就足够了。

zlib is contained in the core Qt libraries. If you want to use the zlib functions in a Qt program, you only have to include zlib.h which is in src/3rdparty/zlib. See e.g. the implementation of QByteArray in src/corelib/tools.

If you want to use quazip, just add the library to your project. It is based on the Qt libraries. Take care to build the correct qyazip library that corresponds to your Qt installation.

You get the correct include path by adding the following line to your project file:

INCLUDEPATH += $[QT_INSTALL_PREFIX]/src/3rdparty/zlib

For Qt5, see Thorbjørn's comment: it is sufficient to use #include <QtZlib/zlib.h>.

煮酒 2024-10-14 21:30:52

目前的答案仅对Qt4有效。从 Qt5 开始,zlib 头文件存储在不同的目录中。使用 qmake 属性 QT_INSTALL_HEADERS 您可以添加到您的 .pro 文件:

INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib

如果您将其添加到quazip.pro

属性 $$[QT_INSTALL_HEADERS] 指向 QTDIR/qtbase/include/,其中包含 QtZlib/zlib.h。

在不更改包含路径的情况下,您必须将每个包含语句更改为 #include 正如 Thorbjørn 所评论的那样。

The current answer is only valid for Qt4. Since Qt5 the zlib header file is stored in a different directory. Using the qmake property QT_INSTALL_HEADERS you can add to your .pro file:

INCLUDEPATH += $$[QT_INSTALL_HEADERS]/QtZlib

This works e.g. to build quazip, if you add it to quazip.pro

The property $$[QT_INSTALL_HEADERS] points to QTDIR/qtbase/include/ within which lies QtZlib/zlib.h.

Without changing the includepath you have to change every include-statement to #include <QtZlib/zlib.h> as commented by Thorbjørn.

℉服软 2024-10-14 21:30:52

如果您想使用 zlib 进行压缩/解压缩,请使用 qCompress/qUncompress

If you want to use zlib for compression/uncompression, use qCompress/qUncompress.

小糖芽 2024-10-14 21:30:52

至少这里有些人想要构建 Quazip,这需要 zlib。

以下是我在 Windows 上使用 quazip 0.4.3 执行此操作的方法。

首先在 quazip.pro 中,我将 SUBDIRS 更改为仅包含:

SUBDIRS=quazip

然后我从以下位置下载了 zlib 二进制文件和源代码:
http://www.winimage.com/zLibDll/zlib125dll.zip [二进制文件]
http://www.winimage.com/zLibDll/zlib125.zip [来源]

两者链接来自 http://zlib.net

然后在子文件夹 quazip/quazip.pro 中添加:

INCLUDEPATH += <path to zlib source>

在 win32 {}我评论了这一行:

#  *-msvc*: QMAKE_LFLAGS += /IMPLIB:$DESTDIR\\quazip.lib

我将 LIBS 行修改为:

*-msvc*: LIBS += -lzlibwapi -L<path to zlib binaries>/dll32

我还在 zip.c 和 unzip.c 中修改

#include "zlib.h"

为:

#include <zlib.h>

之后我将其构建为发布模式并获取了 DLL。

然后在使用它的项目中,我添加了以下配置:

INCLUDEPATH += <quazip source path>
INCLUDEPATH += <zlib source path>

LIBS += -L<quazip source path>\quazip\release -lquazip

并且可以构建并运行,但仅在测试应用程序的发布模式下。在调试模式下,我收到断言错误并且失败。

At least some people here want to build Quazip, which requires zlib.

Here's how I did it on windows with quazip 0.4.3.

First in the quazip.pro I changed SUBDIRS to contain only:

SUBDIRS=quazip

Then I downloaded zlib binaries and source from:
http://www.winimage.com/zLibDll/zlib125dll.zip [binaries]
http://www.winimage.com/zLibDll/zlib125.zip [source]

both links came from http://zlib.net

Then in the subfolder quazip/quazip.pro I added:

INCLUDEPATH += <path to zlib source>

in the win32 {} section I commented this line:

#  *-msvc*: QMAKE_LFLAGS += /IMPLIB:$DESTDIR\\quazip.lib

and I modified the LIBS line to this:

*-msvc*: LIBS += -lzlibwapi -L<path to zlib binaries>/dll32

I also modified in zip.c and unzip.c the

#include "zlib.h"

to become:

#include <zlib.h>

After that I build this to Release mode and got a DLL out.

Then in the project to use this, I added the following config:

INCLUDEPATH += <quazip source path>
INCLUDEPATH += <zlib source path>

LIBS += -L<quazip source path>\quazip\release -lquazip

And that builds and works, but only in Release mode for the test app. In Debug mode i get assertion errors and it fails.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文