我试图让这个Qt项目构建,但我遇到了与zLib有关的Undefined symbol
错误:
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文件中包含这些行:
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的方式:
#include <zlib/zconf.h>
#include <zlib/zlib.h>
我对Qt,C ++和zLib非常陌生。将zlib包含在Qt / C ++项目中的正确方法是什么?
答案 0 :(得分:0)
请尝试下一个解决方案。
您可以通过文本搜索找到定义的ZipPrivate :: createEntry和UnzipPrivate :: extractFile,并将这些文件包含在INCLUDEPATH或HEADERS中。
错误看起来像CONFIG变量的丢失选项。找到的选项将在项目中启用支持zlib。我目前不知道这个选项。