在 Qt 项目中包含 zLib 的正确方法是什么? [英] What is the correct way to include zLib in a Qt project?

查看:42
本文介绍了在 Qt 项目中包含 zLib 的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建这个 Qt 项目,但是遇到了与 zLib 有关的这些 Undefined symbol 错误:

I'm trying to get this Qt project building, but I'm running into these Undefined symbol error having to do with zLib:

Undefined symbols for architecture x86_64:
  "_z_crc32", referenced from:
      ZipPrivate::createEntry(QFileInfo const&, QString const&, Zip::CompressionLevel) in zip.o
      UnzipPrivate::extractFile(QString const&, ZipEntryP const&, QIODevice*, QFlags<UnZip::ExtractionOption>) in unzip.o
  "_z_deflate", referenced from:
      ZipPrivate::createEntry(QFileInfo const&, QString const&, Zip::CompressionLevel) in zip.o
  "_z_deflateEnd", referenced from:
      ZipPrivate::createEntry(QFileInfo const&, QString const&, Zip::CompressionLevel) in zip.o
  "_z_deflateInit2_", referenced from:
      ZipPrivate::createEntry(QFileInfo const&, QString const&, Zip::CompressionLevel) in zip.o
  "_z_get_crc_table", referenced from:
      ZipPrivate::ZipPrivate() in zip.o
      UnzipPrivate::UnzipPrivate() in unzip.o
  "_z_inflate", referenced from:
      UnzipPrivate::extractFile(QString const&, ZipEntryP const&, QIODevice*, QFlags<UnZip::ExtractionOption>) in unzip.o
  "_z_inflateEnd", referenced from:
      UnzipPrivate::extractFile(QString const&, ZipEntryP const&, QIODevice*, QFlags<UnZip::ExtractionOption>) in unzip.o
  "_z_inflateInit2_", referenced from:
      UnzipPrivate::extractFile(QString const&, ZipEntryP const&, QIODevice*, QFlags<UnZip::ExtractionOption>) in unzip.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我的项目中有一个 zlib 文件夹,我包含了 zlib/zconf.h(zlib 目录是 /usr/local 的符号链接/opt/zlib/include) 和 zlib/zlib.h.我将这些行包含在我的 .pro 文件中:

I have a zlib folder in my project and I'm including zlib/zconf.h (the zlib directory is a symlink to /usr/local/opt/zlib/include) and zlib/zlib.h. I'm including these lines in my .pro file:

LIBS += -L/usr/local/opt/zlib/lib
INCLUDEPATH += /usr/local/opt/zlib/include
HEADERS += /usr/local/opt/zlib/include/zconf.h
HEADERS += /usr/local/opt/zlib/include/zlib.h

这是我导入 zlib 的方式:

And here is how I'm importing zlib:

#include <zlib/zconf.h>
#include <zlib/zlib.h>

我对 Qt、C++ 和 zLib 非常陌生.在 Qt/C++ 项目中包含 zlib 的正确方法是什么?

I'm very new to Qt, C++, and zLib. What is the correct way of including zlib in a Qt/C++ project?

推荐答案

请尝试下一个解决方案.

Please try next solutions.

  1. Qt 中的 zlib - QtZlib 不存在

您可以通过文本搜索找到定义了 ZipPrivate::createEntry 和 UnzipPrivate::extractFile 的位置,并将这些文件包含到 INCLUDEPATH 或 HEADERS 中.

You can found by text search where defined ZipPrivate::createEntry and UnzipPrivate::extractFile and include that files into INCLUDEPATH or HEADERS.

错误看起来像是 CONFIG 变量丢失的选项.找到将在您的项目中打开支持 zlib 的选项.我目前不知道该选项.

Error looks like lost option for CONFIG variable. Found option that will switch on support zlib in your project. I don't know that option at the moment.

这篇关于在 Qt 项目中包含 zLib 的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆