Quazip-1.3 static linking issue
-
Seems like you forgot to install QuaZip...
add
-DCMAKE_INSTALL_PREFIX="C:/ZipDev/QuaZip"
to the first cmake call (the configuration) and, after the build, callcmake --build C:/ZipDev/quazip-1.3/msvc2019/static/x86/debug --config Debug --target install
. You will now have the Quazip library installed inC:/ZipDev/QuaZip
that you can reference in your .pro file -
I have tried your solution but it still leads to these linking errors.
.pro file:
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/include/QuaZip-Qt5-1.3/quazip" INCLUDEPATH += "C:/ZipDev/zlib-win-build-1.2.12" CONFIG(debug, debug|release) { DESTDIR = $$OUT_PWD/debug LIBS += -L"C:/ZipDev/QuaZip/lib" -lquazip1-qt5d LIBS += -L"C:/ZipDev/zlib-win-build-1.2.12/build-VS2019-MT/Debug" -llibz-static } #QMAKE_POST_LINK = $$(QTDIR)/bin/windeployqt.exe $$shell_quote($$DESTDIR/$$shell_quote($$TARGET).exe) --no-compiler-runtime
Full error log: https://pastebin.com/raw/GL0tK7xV
-
@Cobra91151 said in Quazip-1.3 static linking issue:
The content of C:/ZipDev/QuaZip folder:
Looks good.
#include "JlCompress.h"
Did you try to unpack QuaZip directly in your source code? Do you have another instance of
JlCompress.h
in your source tree? If so delete it and also change it to#include <JlCompress.h>
just in case -
No, my project source code is available:
C:\Users\cobra\Documents\Projects\CPP\QuaZipTest
QuaZip
is installed:C:\ZipDev\QuaZip
I have only 1 instance ofJlCompress
in the source tree, please check out the following screenshot:I changed to
<JlCompress.h>
but it still displays these errors. -
I have tried to unpack
QuaZip
directly to the source code:.pro file: 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/include/QuaZip-Qt5-1.3/quazip" #INCLUDEPATH += "C:/ZipDev/zlib-win-build-1.2.12" CONFIG(debug, debug|release) { DESTDIR = $$OUT_PWD/debug LIBS += -L"C:/Users/cobra/Documents/Projects/CPP/QuaZipTest" -lquazip1-qt5d LIBS += -L"C:/ZipDev/zlib-win-build-1.2.12/build-VS2019-MT/Debug" -llibz-static } #QMAKE_POST_LINK = $$(QTDIR)/bin/windeployqt.exe $$shell_quote($$DESTDIR/$$shell_quote($$TARGET).exe) --no-compiler-runtime HEADERS += \ JlCompress.h \ ioapi.h \ minizip_crypt.h \ quaadler32.h \ quachecksum32.h \ quacrc32.h \ quagzipfile.h \ quaziodevice.h \ quazip.h \ quazip_global.h \ quazip_qt_compat.h \ quazipdir.h \ quazipfile.h \ quazipfileinfo.h \ quazipnewinfo.h \ unzip.h \ zconf.h \ zip.h \ zlib.h
The same issues are still exists. Compilation log: https://pastebin.com/raw/sPKErHen
-
I have an idea. When selecting
cmake
compiler:-G "Visual Studio 16 2019" -A "Win32"
It produces the following output:
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19044. -- The C compiler identification is MSVC 19.29.30143.0 -- The CXX compiler identification is MSVC 19.29.30143.0
So, I will try to build it using VS 2022:
-G "Visual Studio 17 2022" -A "Win32"
to check for such issues. -
@Cobra91151 said in Quazip-1.3 static linking issue:
I have tried to unpack QuaZip directly to the source code:
No, that's a mess, please revert.
When selecting cmake compiler: -G "Visual Studio 16 2019" -A "Win32"
I wouldn't bother, just use
-G"NMake Makefiles"
, it's a bit slower but QuaZip is not a big project and that will automatically select the compiler you are using and you won't even need to specify--config Debug
.In any case, this does not seem like a problem in the QuaZip build side. The library is installed correctly so that side worked, the problem is in your program using it. Can you try with a brand new project?
-
I know, it is the mess. That's why I always linking instead of unpacking everything to the source. Actually, this is the brand new project which I have created to test
Quazip
because in my real project it leads to the same issues. Previously, I have used thequazip-0.9.1
and it worked without issue. This issue is only withQuazip-1.3
. I do not think it is related to the program. I think, something is wrong withQuazip
static library. Anyway, I will try my and your solution:-G"NMake Makefiles"
and reply soon. -
I have tried both solutions with
VS 2022
andNMake Makefiles
, but it still displays these linking errors. So, I have found this old article: https://forum.qt.io/topic/8492/solved-cannot-get-quazip-test-to-work/2, it maked as solved but I can not find the actual post with a solution. Any ideas? -
QuaZip
VS solution uses by default:Use Multi-Byte Character Set
and it could be changed to:Use Unicode Character Set
orNot Set
.
When I try to add my test project usingVS 2019
->Qt extension
, it displays the charset as:Not Set
.
So, I think it could beUse Unicode Character Set
or better to set theNot Set
option for thisQuaZip
static library when buildingQuaZip
lib. -
@Cobra91151 said in Quazip-1.3 static linking issue:
drop QuaZip and create my own library
That's a giant leap.
- try compilying it dinamically and use it as a dll, why not
- consider alternatives, like KArchive
-
Using DLL is not an option in my case because it must be only
.exe
file for installer. I do not thinkKArchive
is worth trying since it could be the same issue at some point. I prefer code it by my own and have a full control over it. Simple lib to zip/unzip archives wrapper for Qt. Thanks. -
Hello!
I have created my own
CZip
library which adds content to archive and extracts it.
The issue is resolved.