Solved QuaZip - Undefined Reference
-
Hey!
I have a problem when I want to add QuaZip to my project. I get 100 "undefined reference" errors, which is a result of a linking problem iirc.
include(util/singleApplication/singleapplication.pri) include(util/quazip-0.9.1/quazip.pri) LIBS += -lz QT += core gui network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QAPPLICATION_CLASS=QApplication # You can also make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ const/commonfilepaths.cpp \ const/commonfolderpaths.cpp \ const/commonmessageboxes.cpp \ const/sources.cpp \ fetcher/builddownloadinfofetcher.cpp \ fetcher/buildinfofetcher.cpp \ dialog/buildpathdialog.cpp \ dialog/downloadbuildsdialog.cpp \ util/buildpathsmanager.cpp \ util/dolphinbuildscanner.cpp \ util/qeasyfile.cpp \ util/stylesheetloader.cpp \ view/buildoptionsview.cpp \ view/buildtreeview.cpp \ main.cpp \ mainwindow.cpp \ util/filedownloader.cpp \ util/hashfetcher.cpp \ view/generaloptionsview.cpp HEADERS += \ const/commonfilepaths.h \ const/commonfolderpaths.h \ const/commonmessageboxes.h \ const/sources.h \ fetcher/builddownloadinfofetcher.h \ fetcher/buildinfofetcher.h \ dialog/buildpathdialog.h \ dialog/downloadbuildsdialog.h \ struct/buildpathentry.h \ struct/dolphinbuild.h \ util/buildpathsmanager.h \ util/dolphinbuildscanner.h \ util/qeasyfile.h \ view/buildoptionsview.h \ view/buildtreeview.h \ mainwindow.h \ util/stylesheetloader.h \ util/filedownloader.h \ util/hashfetcher.h \ view/generaloptionsview.h FORMS += \ dialog/buildpathdialog.ui \ dialog/downloadbuildsdialog.ui \ mainwindow.ui RESOURCES += resources.qrc
What am I doing wrong? The line
LIBS += -lz
should import the integrated zlib dependeny from QT so I don't see what I'm doing wrong here. -
@FluentCoding
I only seen it here on forums. I compiled it once in linux but not tried on
Windows hence my questions to see what zlib you used.
if binary, i think its a compiler mismatch issue you are seeing.I used
https://github.com/kuba--/zip
which is very small and easy to use/compile but
only support zip files.
But for my use case it was ok and speed and compression is super. -
@FluentCoding
maybe your issue is solved by simply rerunning qmake and do a full rebuild? -
This post is deleted! -
@raven-worx
No, it didn't work :( I rebuilt it and also tried to create a Release Build besides a Debug one but the same error still occurs. -
Can anyone help me? :/
-
@FluentCoding said in QuaZip - Undefined Reference:
QuaZip
Hi
Did you compile all of QuaZip yourself so we know the compiler used for app and for lib is the same and therefore compatible?
OR did you download a precompiled lib and try to link to that ?Often undefined reference comes down to
32/64 bit mismatch
compiler mismatch
It simply don't find itYou do have zlib installed in a normal system place for your platform ?
-
@FluentCoding
I think this project is supposed to be linked as library, not directly added to other projects.
And what you are doing is something like static linking. So I think you should addDEFINES += QUAZIP_STATIC
to your .pro file.
Otherwide the headers will think the classes as "dllimport" -
@mrjj https://github.com/stachenov/quazip I've downloaded the source and just included it to the project. I also tried to build it but I got some errors. I also have installed zlib but it didn't work, I've uninstalled it. I then added the line
LIBS += -lz
so that QT's internal zlib library gets added but that didn't work either.@Bonnie I have already tried it and it didn't work either. It also didn't remove the dllimport warnings.
-
Windows or linux ?
-
@mrjj Win10
-
@FluentCoding
Ok did you see
"Also note that you may or may not need to define ZLIB_WINAPI (qmake DEFINES+=ZLIB_WINAPI) when linking to zlib on Windows, depending on how zlib was built (generally, if using zlibwapi.dll, this define is needed)."From where did you install zlib ?
-
@mrjj From their homepage (the *.msi installer)
-
@FluentCoding
https://zlib.net/ ?
and then some of external links ?I wondering if its for older compiler if not source code.
-
No, don't think so. Have you ever worked with QuaZip? Or are you aware of any good alternative? I was unlucky with KArchive too.
-
@FluentCoding
I only seen it here on forums. I compiled it once in linux but not tried on
Windows hence my questions to see what zlib you used.
if binary, i think its a compiler mismatch issue you are seeing.I used
https://github.com/kuba--/zip
which is very small and easy to use/compile but
only support zip files.
But for my use case it was ok and speed and compression is super. -
@mrjj Thats perfect, thanks! I only need it for zip iirc.
-
@FluentCoding
Ok :)
Do note.It has no recursive function to add all files in all folders but using Qt that is not hard to add.
I tested it with a 1 GB zip file which it handled ok. I cannot say for larger.
It does not support 64 bit zip file so if you get yours from an external source it might be an issue.
-
Oh aight. Btw is it possible to open a zip file from a QByteArray (from memory generally)? @mrjj
-
@FluentCoding said in QuaZip - Undefined Reference:
Btw is it possible to open a zip file from a QByteArray (from memory generally)?
yes
-
@Christian-Ehrlicher How, if I may ask? I haven't found the appropiate method for that.