Create and read from zip file with custom extension?
-
@Christian-Ehrlicher ok but do i need to download zlib before extra or not? The code i posted worked by just including #include <QtZlib/zlib.h>. I did not download zlib extra.
-
Christian Ehrlicher Lifetime Qt Championreplied to StudentScripter on last edited by Christian Ehrlicher
@StudentScripter said in Create and read from zip file with custom extension?:
ok but do i need to download zlib before extra or not? T
I really wonder why people write documentation when noone is reading it... RTM
-
EDIT: fixed most problems, the only error i cant get fixed is:
C:\Users\Musik\Desktop\TestProjektQTKSP\quazip-0.7.3\quazip\quazipdir.cpp:393: error: cannot convert 'QList<QuaZipFileInfo64>::iterator' to 'size_t' {aka 'long long unsigned int'} ..\..\quazip-0.7.3\quazip\quazipdir.cpp: In member function 'bool QuaZipDirPrivate::entryInfoList(QStringList, QDir::Filters, QDir::SortFlags, TFileInfoList&) const': ..\..\quazip-0.7.3\quazip\quazipdir.cpp:393:37: error: cannot convert 'QList<QuaZipFileInfo64>::iterator' to 'size_t' {aka 'long long unsigned int'} 393 | qsort(list.begin(), list.end(), lessThan); | ~~~~~~~~^~ | | | QList<QuaZipFileInfo64>::iterator
.
.
.
.
.
.Sorry may im dumb but i've never done something like this before. Tried to read the documentation, watched the videos of Voidrealms (https://www.youtube.com/watch?v=mxlcKmvMK9Q&list=PL2D1942A4688E9D63&index=112) but things really changed since 9 years ago. In the precompiled version there are no .so files like in the tutorial, zlib1.dll is now named zlibwapi.dll and as someone who has never done something like that before im really stuck.
I know this pisses you of as an advanced programmer so help me or help me not but im really stuck. I've downloaded the prebuild zlib.dll zip and extracted it but how do i actually use it in my project now? What do i have to do: http://www.winimage.com/zLibDll/
I also tried everything like in the video of Voidrealms but i only get errors when trying to build the quazip.pro:C:\Users\Musik\Desktop\TestProjektQTKSP\quazip-0.7.3\quazip\quazip.h:37: error: QTextCodec: No such file or directory In file included from ..\..\quazip-0.7.3\quazip\JlCompress.h:29, from ..\..\quazip-0.7.3\quazip\JlCompress.cpp:26: ..\..\quazip-0.7.3\quazip\quazip.h:37:10: fatal error: QTextCodec: No such file or directory 37 | #include <QTextCodec> | ^~~~~~~~~~~~ :-1: error: [Makefile.Debug:744: debug/JlCompress.o] Error 1 C:\Users\Musik\Desktop\TestProjektQTKSP\quazip-0.7.3\quazip\quazip.h:37: error: QTextCodec: No such file or directory In file included from ..\..\quazip-0.7.3\quazip\quazip.cpp:29: ..\..\quazip-0.7.3\quazip\quazip.h:37:10: fatal error: QTextCodec: No such file or directory 37 | #include <QTextCodec> | ^~~~~~~~~~~~ C:\Users\Musik\Desktop\TestProjektQTKSP\quazip-0.7.3\quazip\quazip.h:37: error: QTextCodec: No such file or directory In file included from ..\..\quazip-0.7.3\quazip\quazipdir.h:30, from ..\..\quazip-0.7.3\quazip\quazipdir.cpp:25: ..\..\quazip-0.7.3\quazip\quazip.h:37:10: fatal error: QTextCodec: No such file or directory 37 | #include <QTextCodec> | ^~~~~~~~~~~~ C:\Users\Musik\Desktop\TestProjektQTKSP\quazip-0.7.3\quazip\quazip.h:37: error: QTextCodec: No such file or directory In file included from ..\..\quazip-0.7.3\quazip\quazipfile.h:31, from ..\..\quazip-0.7.3\quazip\quazipfile.cpp:25: ..\..\quazip-0.7.3\quazip\quazip.h:37:10: fatal error: QTextCodec: No such file or directory 37 | #include <QTextCodec> | ^~~~~~~~~~~~ C:\Users\Musik\Desktop\TestProjektQTKSP\quazip-0.7.3\quazip\quazipfileinfo.cpp:29: error: invalid conversion from 'int' to 'QFileDevice::Permission' [-fpermissive] ..\..\quazip-0.7.3\quazip\quazipfileinfo.cpp: In function 'QFileDevice::Permissions permissionsFromExternalAttr(quint32)': ..\..\quazip-0.7.3\quazip\quazipfileinfo.cpp:29:31: error: invalid conversion from 'int' to 'QFileDevice::Permission' [-fpermissive] 29 | QFile::Permissions perm = 0; | ^ | | | int C:\Users\Musik\Documents\Qt\6.5.2\mingw_64\include\QtCore\qglobal.h:50: In file included from ../../../../Documents/Qt/6.5.2/mingw_64/include/QtCore/qglobal.h:50, In file included from ../../../../Documents/Qt/6.5.2/mingw_64/include/QtCore/qglobal.h:50, from ../../../../Documents/Qt/6.5.2/mingw_64/include/QtCore/qatomic.h:5, from ../../../../Documents/Qt/6.5.2/mingw_64/include/QtCore/qrefcount.h:7, from ../../../../Documents/Qt/6.5.2/mingw_64/include/QtCore/qbytearray.h:8, from ../../../../Documents/Qt/6.5.2/mingw_64/include/QtCore/QByteArray:1, from ..\..\quazip-0.7.3\quazip\quazipfileinfo.h:28, from ..\..\quazip-0.7.3\quazip\quazipfileinfo.cpp:25: ../../../../Documents/Qt/6.5.2/mingw_64/include/QtCore/qflags.h:74:45: note: initializing argument 1 of 'constexpr QFlags<T>::QFlags(Enum) [with Enum = QFileDevice::Permission]' 74 | constexpr inline Q_IMPLICIT QFlags(Enum flags) noexcept : i(Int(flags)) {} | ~~~~~^~~~~ C:\Users\Musik\Desktop\TestProjektQTKSP\quazip-0.7.3\quazip\quazipnewinfo.cpp:137: error: 'class QFileInfo' has no member named 'created' ..\..\quazip-0.7.3\quazip\quazipnewinfo.cpp: In member function 'void QuaZipNewInfo::setFileNTFSTimes(const QString&)': ..\..\quazip-0.7.3\quazip\quazipnewinfo.cpp:137:25: error: 'class QFileInfo' has no member named 'created' 137 | setFileNTFScTime(fi.created()); | ^~~~~~~
EDIT: I fixed one error by including: #include <QtCore5Compat/QTextCodec> instead of just QTextCodec but still errors remain.
created() was switched to birthTime(), QString::SkipEmptyParts switched to Qt::SkipEmptyParts. Changed to: QFile::Permissions perm = static_castQFileDevice::Permission(0);
and: return compressDir(fileCompressed, dir, recursive, static_castQDir::Filter(0)); -
Have you tried to use
-D QUAZIP_USE_QT_ZLIB=ON
before you install zlib? -
@Pl45m4 No how do i use that? I only downloaded the quazip source files and opened the quazip.pro file with qt creator (like in VoidRealms tutorial). For zlib i downloaded the precompiled windows version.
quazip.pro file looks like this:
i added zlib.h to the project headder files aswell as zconf.h
TEMPLATE = lib CONFIG += qt warn_on QT -= gui # The ABI version. !win32:VERSION = 1.0.0 # 1.0.0 is the first stable ABI. # The next binary incompatible change will be 2.0.0 and so on. # The existing QuaZIP policy on changing ABI requires to bump the # major version of QuaZIP itself as well. Note that there may be # other reasons for chaging the major version of QuaZIP, so # in case where there is a QuaZIP major version bump but no ABI change, # the VERSION variable will stay the same. # For example: # QuaZIP 1.0 is released after some 0.x, keeping binary compatibility. # VERSION stays 1.0.0. # Then some binary incompatible change is introduced. QuaZIP goes up to # 2.0, VERSION to 2.0.0. # And so on. # This one handles dllimport/dllexport directives. DEFINES += QUAZIP_BUILD # You'll need to define this one manually if using a build system other # than qmake or using QuaZIP sources directly in your project. CONFIG(staticlib): DEFINES += QUAZIP_STATIC LIBDIR += "C:/Users/Musik/Desktop/TestProjektQTKSP/Libs" INCLUDEPATH += $${LIBDIR} win32 { LIB += -L$${LIBDIR} -lzdll } win64 { LIB += -L$${LIBDIR} -lzdll } # Input include(quazip.pri) CONFIG(debug, debug|release) { mac: TARGET = $$join(TARGET,,,_debug) win32: TARGET = $$join(TARGET,,,d) } unix:!symbian { headers.path=$$PREFIX/include/quazip headers.files=$$HEADERS target.path=$$PREFIX/lib/$${LIB_ARCH} INSTALLS += headers target OBJECTS_DIR=.obj MOC_DIR=.moc } win32 { headers.path=$$PREFIX/include/quazip headers.files=$$HEADERS target.path=$$PREFIX/lib INSTALLS += headers target # workaround for qdatetime.h macro bug DEFINES += NOMINMAX } symbian { # Note, on Symbian you may run into troubles with LGPL. # The point is, if your application uses some version of QuaZip, # and a newer binary compatible version of QuaZip is released, then # the users of your application must be able to relink it with the # new QuaZip version. For example, to take advantage of some QuaZip # bug fixes. # This is probably best achieved by building QuaZip as a static # library and providing linkable object files of your application, # so users can relink it. CONFIG += staticlib CONFIG += debug_and_release LIBS += -lezip #Export headers to SDK Epoc32/include directory exportheaders.sources = $$HEADERS exportheaders.path = quazip for(header, exportheaders.sources) { BLD_INF_RULES.prj_exports += "$$header $$exportheaders.path/$$basename(header)" } } HEADERS +=
-
@StudentScripter Which version are you trying to build ?
The latest code uses CMake as build system and what you show is using qmake.
-
@SGaist Im trying to build for qt 6.5 using cmake (but i never had to configure something as i did not use external libraries, but now i need to) Just fiddling around with qt and c++ for a few months and by far no professional programmer. So yeah the dumb questions aren't meant rude or lazy in any way. Been researching steadily, but it's really hard to graps and get everything if you have never done it before. :)
So if you could hint me the way on how to do that, simple step by step, that would really help. I would really appreciate that. I also take good YT tutorials.
Anyway have a nice christmas day. :D
-
You should use the latest version and not some ancient ones: https://github.com/stachenov/quazip/releases
-
-
I downloaded QuaZip v1.4 and unzipped it
-
I downloaded zlib (the precompiled dll and source code from here: http://www.winimage.com/zLibDll/)
-
I copyied the zlibwapi.dll, zlib_bor.lib, zlibwapi.lib to an extra folder:
-
I took the zlib.h and zconf.h from the source files and copied it into the quazip folder:
5) What to do next? Or should i do something different?
-
-
@Christian-Ehrlicher @SGaist I simply opened the cmake file inside the quazip folder with qt:
i tried adding the paths to my library and includes as mentioned the post above but no luck, build is grayed out...
# require 3.15 for GNUInstallDirs cmake_minimum_required(VERSION 3.15...3.18) project(QuaZip VERSION 1.4) include(cmake/clone-repo.cmake) set(QUAZIP_LIB_VERSION ${QuaZip_VERSION}) set(QUAZIP_LIB_SOVERSION 1.4.0) if(EMSCRIPTEN) option(ZLIB_INCLUDE "Path to include dir" "C:/Users/Musik/Desktop/TestProjektQTKSP/quazip-1.4/quazip") option(ZLIB_LIBRARY "Path to library dir" "C:/Users/Musik/Desktop/TestProjektQTKSP/quazip-1.4/Libs") option(BUILD_SHARED_LIBS "" OFF) option(QUAZIP_INSTALL "" OFF) option(QUAZIP_USE_QT_ZLIB "" OFF) option(QUAZIP_ENABLE_TESTS "Build QuaZip tests" OFF) else() option(BUILD_SHARED_LIBS "" ON) option(QUAZIP_INSTALL "" ON) option(QUAZIP_USE_QT_ZLIB "" OFF) option(QUAZIP_ENABLE_TESTS "Build QuaZip tests" OFF) endif() # Make BZIP2 optional option(QUAZIP_BZIP2 "Enables BZIP2 compression" ON) option(QUAZIP_BZIP2_STDIO "Output BZIP2 errors to stdio" ON) option(QUAZIP_FETCH_LIBS "Enables fetching third-party libraries if not found" ${WIN32}) option(QUAZIP_FORCE_FETCH_LIBS "Enables fetching third-party libraries always" OFF) # Set the default value of `${QUAZIP_QT_MAJOR_VERSION}`. # We search quietly for Qt6, Qt5 and Qt4 in that order. # Qt6 and Qt5 provide config files for CMake. # Qt4 relies on `FindQt4.cmake`. find_package( QT NAMES Qt6 Qt5 QUIET COMPONENTS Core ) if (NOT QT_FOUND) find_package(Qt4 QUIET COMPONENTS QtCore) if (Qt4_FOUND) set(QT_VERSION_MAJOR 4) else() # If neither 6, 5 nor 4 are found, we default to 5. # The setup will fail further down. set(QT_VERSION_MAJOR 5) endif() endif() set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}") if (QUAZIP_QT_MAJOR_VERSION EQUAL 6) set(CMAKE_CXX_STANDARD 17) else() set(CMAKE_CXX_STANDARD 14) endif() if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RELEASE) endif() set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_DEBUG_POSTFIX d) set(QUAZIP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(QUAZIP_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(QUAZIP_LIB_FILE_NAME quazip${QuaZip_VERSION_MAJOR}-qt${QUAZIP_QT_MAJOR_VERSION}) set(QUAZIP_LIB_TARGET_NAME QuaZip) set(QUAZIP_DIR_NAME QuaZip-Qt${QUAZIP_QT_MAJOR_VERSION}-${QUAZIP_LIB_VERSION}) set(QUAZIP_PACKAGE_NAME QuaZip-Qt${QUAZIP_QT_MAJOR_VERSION}) if(QUAZIP_QT_MAJOR_VERSION EQUAL 6) find_package(Qt6 REQUIRED COMPONENTS Core Core5Compat OPTIONAL_COMPONENTS Network Test) set(QUAZIP_LIB_LIBRARIES Qt6::Core Qt6::Core5Compat) set(QUAZIP_TEST_QT_LIBRARIES Qt6::Core Qt6::Core5Compat Qt6::Network Qt6::Test) set(QUAZIP_PKGCONFIG_REQUIRES "zlib, Qt6Core") elseif(QUAZIP_QT_MAJOR_VERSION EQUAL 5) find_package(Qt5 REQUIRED COMPONENTS Core OPTIONAL_COMPONENTS Network Test) set(QUAZIP_LIB_LIBRARIES Qt5::Core) set(QUAZIP_TEST_QT_LIBRARIES Qt5::Core Qt5::Network Qt5::Test) set(QUAZIP_PKGCONFIG_REQUIRES "zlib, Qt5Core") elseif(QUAZIP_QT_MAJOR_VERSION EQUAL 4) find_package(Qt4 4.5.0 REQUIRED COMPONENTS QtCore OPTIONAL_COMPONENTS QtNetwork QtTest) set(QUAZIP_LIB_LIBRARIES Qt4::QtCore) set(QUAZIP_TEST_QT_LIBRARIES Qt4::QtCore Qt4::QtNetwork Qt4::QtTest) set(QUAZIP_PKGCONFIG_REQUIRES "zlib, QtCore") else() message(FATAL_ERROR "Qt version ${QUAZIP_QT_MAJOR_VERSION} is not supported") endif() message(STATUS "Using Qt version ${QUAZIP_QT_MAJOR_VERSION}") set(QUAZIP_QT_ZLIB_USED OFF) if(QUAZIP_USE_QT_ZLIB) find_package(Qt${QUAZIP_QT_MAJOR_VERSION} OPTIONAL_COMPONENTS Zlib) if (Qt${QUAZIP_QT_MAJOR_VERSION}Zlib_FOUND) set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::Zlib) set(QUAZIP_QT_ZLIB_USED ON) endif() endif() if(NOT QUAZIP_QT_ZLIB_USED) if(EMSCRIPTEN) if(NOT DEFINED ZLIB_LIBRARY) message(WARNING "ZLIB_LIBRARY is not set") endif() if(NOT DEFINED ZLIB_INCLUDE) message(WARNING "ZLIB_INCLUDE is not set") else() include_directories(${ZLIB_INCLUDE}) endif() if(NOT DEFINED ZCONF_INCLUDE) message(WARNING "ZCONF_INCLUDE is not set") else() include_directories(${ZCONF_INCLUDE}) endif() set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} ${ZLIB_LIBRARY}) else() find_package(ZLIB REQUIRED) set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} ZLIB::ZLIB) endif() endif() set(QUAZIP_DEP) set(QUAZIP_INC) set(QUAZIP_LIB) set(QUAZIP_LBD) if(QUAZIP_BZIP2) # Check if bzip2 is present set(QUAZIP_BZIP2 ON) if(NOT QUAZIP_FORCE_FETCH_LIBS) find_package(BZip2 QUIET) endif() if(BZIP2_FOUND AND NOT QUAZIP_FORCE_FETCH_LIBS) message(STATUS "Using BZIP2 ${BZIP2_VERSION_STRING}") list(APPEND QUAZIP_INC ${BZIP2_INCLUDE_DIRS}) list(APPEND QUAZIP_LIB ${BZIP2_LIBRARIES}) list(APPEND QUAZIP_LBD ${BZIP2_LIBRARY_DIRS}) set(PC_PRIVATE_LIBS "${PC_PRIVATE_LIBS} -lbzip2") elseif(QUAZIP_FETCH_LIBS) clone_repo(bzip2 https://sourceware.org/git/bzip2.git) # BZip2 repository does not support cmake so we have to create # the bzip2 library ourselves set(BZIP2_SRC ${BZIP2_SOURCE_DIR}/blocksort.c ${BZIP2_SOURCE_DIR}/bzlib.c ${BZIP2_SOURCE_DIR}/compress.c ${BZIP2_SOURCE_DIR}/crctable.c ${BZIP2_SOURCE_DIR}/decompress.c ${BZIP2_SOURCE_DIR}/huffman.c ${BZIP2_SOURCE_DIR}/randtable.c) set(BZIP2_HDR ${BZIP2_SOURCE_DIR}/bzlib.h ${BZIP2_SOURCE_DIR}/bzlib_private.h) add_library(bzip2 STATIC ${BZIP2_SRC} ${BZIP2_HDR}) if(NOT QUAZIP_BZIP2_STDIO) target_compile_definitions(bzip2 PRIVATE -DBZ_NO_STDIO) endif() list(APPEND QUAZIP_DEP bzip2) list(APPEND QUAZIP_LIB bzip2) list(APPEND QUAZIP_INC ${BZIP2_SOURCE_DIR}) else() message(STATUS "BZip2 library not found") set(QUAZIP_BZIP2 OFF) endif() if(QUAZIP_BZIP2) find_package(BZip2) add_compile_definitions(HAVE_BZIP2) endif() endif() add_subdirectory(quazip) if(QUAZIP_ENABLE_TESTS) message(STATUS "Building QuaZip tests") enable_testing() add_subdirectory(qztest) endif()
-
bumping this
-
@StudentScripter since you do not follow the official documentation no more comments from me anymore...
-
@Christian-Ehrlicher ... i follow the official documentation but guess what... it doesnt work or i get something wrong. Look at my 2 posts above i downloaded the official precompiled dll of zlib i downloaded quazip opened the quazip cmake.txt and wanted to link to zlib but only errors...
AND WELL even when i try to build quazip like in the documentation i get errors too:
And YES i tried to USE the official documentation the last days 5 or 6 times, i really try but i just can't get it to work. Don't want to come of rude, but well it sucks to try countless hours every day to get it working. But just cant get it.Used this:
$ cd /wherever/quazip/source/is/quazip-x.y.z $ cmake -S . -B wherever/you/want/your/build/to/be -D QUAZIP_QT_MAJOR_VERSION=6, 5 or 4 {HERE I GET THE ERROR POSTED ABOVE} $ cmake --build wherever/you/want/your/build/to/be