What is the correct way to include zLib in a Qt project?

十年热恋 提交于 2019-12-11 07:17:57

问题


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)

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

And here is how I'm importing zlib:

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

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


回答1:


Please try next solutions.

  1. zlib in Qt - QtZlib not present

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

  3. 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.



来源:https://stackoverflow.com/questions/47823772/what-is-the-correct-way-to-include-zlib-in-a-qt-project

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!