Solved QuaZip - Undefined Reference
-
@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.
-
@FluentCoding
Hi
Yes it can be both memory and file-based
see section
Extract a zip entry into memory using callback. -
This post is deleted! -
@mrjj Thanks but I meant from memory, not into memory.
-
@FluentCoding
if you mean
Can i add a buffer to the zip file as was it a file then yes :)auto bytes = QByteArray::fromRawData(reinterpret_cast<const char *>(memory), int(fileSize32Bit)); zip_entry_write(zip, bytes, fileSize32Bit);
-
@mrjj Alright - (hopefully the) last question: How can I create zip_t object without
zip_open
, so that i only usezip_entry_write
to add the buffer? Should I just create an object of the structzip_t
? Also, should I replacefileSize32Bit
with the size of the QByteArray?