I have built Quazip-1.3
libs statically with zlib-win-build-1.2.12 (build-VS2019-MT) - libz-static.lib
. When I try to build my project then I get a lot of linking errors:
LINK : warning LNK4217: symbol '?commit@QSaveFile@@QAE_NXZ (public: bool __thiscall QSaveFile::commit(void))' defined in 'Qt5Cored.lib(qsavefile.obj)' is imported by 'quazip1-qt5d.lib(qioapi.obj)' in function '"bool __cdecl quazip_close(class QIODevice *)" (?quazip_close@@YA_NPAVQIODevice@@@Z)'
LINK : warning LNK4217: symbol '?staticMetaObject@QSaveFile@@2UQMetaObject@@B (public: static struct QMetaObject const QSaveFile::staticMetaObject)' defined in 'Qt5Cored.lib(qsavefile.obj)' is imported by 'quazip1-qt5d.lib(qioapi.obj)' in function '"class QSaveFile * __cdecl qobject_cast<class QSaveFile *>(class QObject *)" (??$qobject_cast@PAVQSaveFile@@@@YAPAVQSaveFile@@PAVQObject@@@Z)'
quazip1-qt5d.lib(JlCompress.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QString & __thiscall QString::operator+=(char)" (__imp_??YQString@@QAEAAV0@D@Z) referenced in function "public: static class QStringList __cdecl JlCompress::extractDir(class QuaZip &,class QString const &)" (?extractDir@JlCompress@@SA?AVQStringList@@AAVQuaZip@@ABVQString@@@Z)
Hint on symbols that are defined and could potentially match:
"__declspec(dllimport) public: class QString & __thiscall QString::operator+=(class QString const &)" (__imp_??YQString@@QAEAAV0@ABV0@@Z)
quazip1-qt5d.lib(quazipfileinfo.obj) : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QIODevice * __thiscall QDataStream::device(void)const " (__imp_?device@QDataStream@@QBEPAVQIODevice@@XZ) referenced in function "class QDateTime __cdecl getNTFSTime(class QByteArray const &,int,int *)" (?getNTFSTime@@YA?AVQDateTime@@ABVQByteArray@@HPAH@Z)
debug\QuaZipTest.exe : fatal error LNK1120: 2 unresolved externals
Code:
QuaZipTest.pro:
QT -= gui
CONFIG += c++latest console static
CONFIG -= app_bundle
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
# Default rules for deployment.
#qnx: target.path = /tmp/$${TARGET}/bin
#else: unix:!android: target.path = /opt/$${TARGET}/bin
#!isEmpty(target.path): INSTALLS += target
MOC_DIR = ./resources/moc
OBJECTS_DIR = ./resources/objects
RCC_DIR = ./resources/resource
DEFINES += QUAZIP_STATIC
INCLUDEPATH += "C:/ZipDev/quazip-1.3/quazip"
INCLUDEPATH += "C:/ZipDev/zlib-win-build-1.2.12"
CONFIG(debug, debug|release) {
DESTDIR = $$OUT_PWD/debug
contains(QMAKE_TARGET.arch, x86_64) {
LIBS += -L"C:/ZipDev/quazip-1.3/msvc2019/static/x64/debug/quazip/Debug" -lquazip1-qt5d
LIBS += -L"C:/ZipDev/zlib-win-build-1.2.12/build-VS2019-MT/x64/Debug" -llibz-static
} else {
LIBS += -L"C:/ZipDev/quazip-1.3/msvc2019/static/x86/debug/quazip/Debug" -lquazip1-qt5d
LIBS += -L"C:/ZipDev/zlib-win-build-1.2.12/build-VS2019-MT/Debug" -llibz-static
}
} else {
DESTDIR = $$OUT_PWD/release
contains(QMAKE_TARGET.arch, x86_64) {
LIBS += -L"C:/ZipDev/quazip-1.3/msvc2019/static/x64/release/quazip/Release" -lquazip1-qt5
LIBS += -L"C:/ZipDev/zlib-win-build-1.2.12/build-VS2019-MT/x64/Release" -llibz-static
} else {
LIBS += -L"C:/ZipDev/quazip-1.3/msvc2019/static/x86/release/quazip/Release" -lquazip1-qt5
LIBS += -L"C:/ZipDev/zlib-win-build-1.2.12/build-VS2019-MT/Release" -llibz-static
}
}
#QMAKE_POST_LINK = $$(QTDIR)/bin/windeployqt.exe $$shell_quote($$DESTDIR/$$shell_quote($$TARGET).exe) --no-compiler-runtime
main.cpp:
#include <QCoreApplication>
#include <QTextStream>
#include <QTextCodec>
#include <Windows.h>
#include "JlCompress.h"
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
QTextStream output(stdout);
output.setCodec(QTextCodec::codecForName("IBM 866"));
output << "This is a Quazip test..." << endl;
QString zipPath = "C:\\Users\\cobra\\Downloads\\22598.200_amd64_en-us_professional_7405f8e8_convert.zip";
QString downloadsFolder = "C:\\Users\\cobra\\Downloads\\22598.200_amd64_en-us_professional";
const QStringList extractedDir = JlCompress::extractDir(zipPath, downloadsFolder);
if (!extractedDir.isEmpty()) {
output << "Is empty(): " << "No" << endl;
} else {
output << "Is empty(): " << "Yes" << endl;
}
for (QString extractedFileName : extractedDir) {
output << "Extracting: " << extractedFileName << endl;
}
system("Pause");
return 0;
}
I have used these commands to build QuaZip
statically:
cmake -DCMAKE_BUILD_TYPE="Debug" -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreadedDebug" -DBUILD_SHARED_LIBS=OFF -S . -B C:/ZipDev/quazip-1.3/msvc2019/static/x86/debug -D QUAZIP_QT_MAJOR_VERSION=5 "-DCMAKE_PREFIX_PATH=C:/Qt/5.9.9/msvc2019" -DZLIB_INCLUDE_DIR="C:/ZipDev/zlib-win-build-1.2.12" -DZLIB_LIBRARY="C:/ZipDev/zlib-win-build-1.2.12/build-VS2019-MT/Debug/libz-static.lib" -G "Visual Studio 16 2019" -A "Win32"
cmake --build C:/ZipDev/quazip-1.3/msvc2019/static/x86/debug --config Debug
Also, I have checked the QuaZip
library - quazip1-qt5d.lib
using lib /list
and dumpbin /directives
.
C:\ZipDev\quazip-1.3\msvc2019\static\x86\debug\quazip\Debug>lib /list quazip1-qt5d.lib
Microsoft (R) Library Manager Version 14.29.30143.0
Copyright (C) Microsoft Corporation. All rights reserved.
QuaZip.dir\Debug\mocs_compilation_Debug.obj
QuaZip.dir\Debug\unzip.obj
QuaZip.dir\Debug\zip.obj
QuaZip.dir\Debug\JlCompress.obj
QuaZip.dir\Debug\qioapi.obj
QuaZip.dir\Debug\quaadler32.obj
QuaZip.dir\Debug\quachecksum32.obj
QuaZip.dir\Debug\quacrc32.obj
QuaZip.dir\Debug\quagzipfile.obj
QuaZip.dir\Debug\quaziodevice.obj
QuaZip.dir\Debug\quazip.obj
QuaZip.dir\Debug\quazipdir.obj
QuaZip.dir\Debug\quazipfile.obj
QuaZip.dir\Debug\quazipfileinfo.obj
QuaZip.dir\Debug\quazipnewinfo.obj
C:\ZipDev\quazip-1.3\msvc2019\static\x86\debug\quazip\Debug>
C:\ZipDev\quazip-1.3\msvc2019\static\x86\debug\quazip\Debug>dumpbin /directives quazip1-qt5d.lib
Microsoft (R) COFF/PE Dumper Version 14.29.30143.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file quazip1-qt5d.lib
File Type: LIBRARY
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Linker Directives
-----------------
/FAILIFMISMATCH:_CRT_STDIO_ISO_WIDE_SPECIFIERS=0
/FAILIFMISMATCH:_MSC_VER=1900
/FAILIFMISMATCH:_ITERATOR_DEBUG_LEVEL=2
/FAILIFMISMATCH:RuntimeLibrary=MTd_StaticDebug
/DEFAULTLIB:libcpmtd
/DEFAULTLIB:LIBCMTD
/DEFAULTLIB:OLDNAMES
Summary
28 .CRT$XCU
6C .bss
3150 .chks64
6E .data
1B8 .data$rs
CA550 .debug$S
654 .debug$T
CD1 .drectve
6A85 .rdata
46A .rdata$r
3C .rtc$IMZ
3C .rtc$TMZ
2B8 .sxdata
12C .text$di
2A606 .text$mn
2CD6 .text$x
67C .voltbl
2FA4 .xdata$x
C:\ZipDev\quazip-1.3\msvc2019\static\x86\debug\quazip\Debug>
Full error log: https://pastebin.com/raw/GL0tK7xV
The issue only occurs with Quazip
static libs, dynamic libs are working well. What could cause such errors with static libs? Thank you.
I have created my own
CZip
library which adds content to archive and extracts it. The issue is resolved.