问题
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.
zlib in Qt - QtZlib not present
You can found by text search where defined ZipPrivate::createEntry and UnzipPrivate::extractFile and include that files into INCLUDEPATH or HEADERS.
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