Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Create and read from zip file with custom extension?

Create and read from zip file with custom extension?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt c++ziphelp install
19 Posts 4 Posters 2.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    StudentScripter
    wrote on 23 Dec 2023, 14:57 last edited by StudentScripter
    #1

    Hello i want to create an zip file with all my contents in it (qt c++), however i want the zip to not have the name zip but .mdt (Mydata). In this zip file with the custom extensions will be json file that i than want to read in (i already got the json readin working from a folder, but i want it from a custom zip instead.)

    How can i create a zip with custom extension and read from it? Do i need an external library and if so how do i add/install that into qt? (Newbie question) :)
    Thanks for the help, appreciate that.

    P 1 Reply Last reply 23 Dec 2023, 15:13
    0
    • S StudentScripter
      23 Dec 2023, 14:57

      Hello i want to create an zip file with all my contents in it (qt c++), however i want the zip to not have the name zip but .mdt (Mydata). In this zip file with the custom extensions will be json file that i than want to read in (i already got the json readin working from a folder, but i want it from a custom zip instead.)

      How can i create a zip with custom extension and read from it? Do i need an external library and if so how do i add/install that into qt? (Newbie question) :)
      Thanks for the help, appreciate that.

      P Online
      P Online
      Pl45m4
      wrote on 23 Dec 2023, 15:13 last edited by Pl45m4
      #2

      @StudentScripter

      If it's a correctly formatted and valid zip file, but only a different extension, you can still force your program (any program) to treat it as a regular zip file.
      File extensions are just to assign files to programs. The file codec / content is what matters and decides whether a program can read a file or not.
      So handle it as you would read or extract a standard zip file (with your app or some additional library/tool)


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      S 1 Reply Last reply 23 Dec 2023, 16:26
      3
      • P Pl45m4
        23 Dec 2023, 15:13

        @StudentScripter

        If it's a correctly formatted and valid zip file, but only a different extension, you can still force your program (any program) to treat it as a regular zip file.
        File extensions are just to assign files to programs. The file codec / content is what matters and decides whether a program can read a file or not.
        So handle it as you would read or extract a standard zip file (with your app or some additional library/tool)

        S Offline
        S Offline
        StudentScripter
        wrote on 23 Dec 2023, 16:26 last edited by
        #3

        @Pl45m4 Thank you but how at all to read and write a zip file in qt? Is there a build in solution in qt and how to use it?

        S 1 Reply Last reply 23 Dec 2023, 18:56
        0
        • S StudentScripter
          23 Dec 2023, 16:26

          @Pl45m4 Thank you but how at all to read and write a zip file in qt? Is there a build in solution in qt and how to use it?

          S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 23 Dec 2023, 18:56 last edited by
          #4

          @StudentScripter
          There's Quazip or Karchive.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply 25 Dec 2023, 16:37
          3
          • S SGaist
            23 Dec 2023, 18:56

            @StudentScripter
            There's Quazip or Karchive.

            S Offline
            S Offline
            StudentScripter
            wrote on 25 Dec 2023, 16:37 last edited by
            #5

            @SGaist Thank you how can i install Quazip.

            I've just added the #include <QtZlib/zlib.h> in my project so zLib should be fine, but how to install and link QuaZip?

            #include "MainWindow.h"
            #include "./ui_MainWindow.h"
            #include <QByteArray>
            #include <QtZlib/zlib.h>
            
            MainWindow::MainWindow(QWidget *parent)
                : QMainWindow(parent)
                , ui(new Ui::MainWindow)
            {
                ui->setupUi(this);
            
                // Testdaten erstellen
                QByteArray originalData = "Testdaten für zlib in Qt und C++";
            
                // Daten komprimieren
                QByteArray compressedData = qCompress(originalData);
            
                // Daten dekomprimieren
                QByteArray decompressedData = qUncompress(compressedData);
            
                // Überprüfen, ob die ursprünglichen Daten und die dekomprimierten Daten übereinstimmen
                if (originalData == decompressedData) {
                    qDebug() << "zlib funktioniert korrekt!";
                } else {
                    qDebug() << "Fehler: zlib funktioniert nicht korrekt.";
                }
            }
            
            MainWindow::~MainWindow()
            {
                delete ui;
            }
            
            
            C 1 Reply Last reply 25 Dec 2023, 16:40
            0
            • S StudentScripter
              25 Dec 2023, 16:37

              @SGaist Thank you how can i install Quazip.

              I've just added the #include <QtZlib/zlib.h> in my project so zLib should be fine, but how to install and link QuaZip?

              #include "MainWindow.h"
              #include "./ui_MainWindow.h"
              #include <QByteArray>
              #include <QtZlib/zlib.h>
              
              MainWindow::MainWindow(QWidget *parent)
                  : QMainWindow(parent)
                  , ui(new Ui::MainWindow)
              {
                  ui->setupUi(this);
              
                  // Testdaten erstellen
                  QByteArray originalData = "Testdaten für zlib in Qt und C++";
              
                  // Daten komprimieren
                  QByteArray compressedData = qCompress(originalData);
              
                  // Daten dekomprimieren
                  QByteArray decompressedData = qUncompress(compressedData);
              
                  // Überprüfen, ob die ursprünglichen Daten und die dekomprimierten Daten übereinstimmen
                  if (originalData == decompressedData) {
                      qDebug() << "zlib funktioniert korrekt!";
                  } else {
                      qDebug() << "Fehler: zlib funktioniert nicht korrekt.";
                  }
              }
              
              MainWindow::~MainWindow()
              {
                  delete ui;
              }
              
              
              C Offline
              C Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 25 Dec 2023, 16:40 last edited by
              #6

              @StudentScripter by clicking on the link @SGaist gave you. There is a nice paragraph in the documentation on how to use and install Quazip.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              S 1 Reply Last reply 25 Dec 2023, 16:47
              0
              • C Christian Ehrlicher
                25 Dec 2023, 16:40

                @StudentScripter by clicking on the link @SGaist gave you. There is a nice paragraph in the documentation on how to use and install Quazip.

                S Offline
                S Offline
                StudentScripter
                wrote on 25 Dec 2023, 16:47 last edited by
                #7

                @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.

                C 1 Reply Last reply 25 Dec 2023, 16:54
                0
                • S StudentScripter
                  25 Dec 2023, 16:47

                  @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.

                  C Offline
                  C Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 25 Dec 2023, 16:54 last edited by Christian Ehrlicher
                  #8

                  @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

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  S 1 Reply Last reply 25 Dec 2023, 18:21
                  2
                  • C Christian Ehrlicher
                    25 Dec 2023, 16:54

                    @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

                    S Offline
                    S Offline
                    StudentScripter
                    wrote on 25 Dec 2023, 18:21 last edited by StudentScripter
                    #9

                    @Christian-Ehrlicher

                    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/
                    521d63ec-ae00-487e-927a-336196f37a57-image.png
                    abb1062a-5d6c-444e-b0bf-5721d574e85c-image.png 5d54f32f-4c99-4935-aa8f-1fa7cb34406c-image.png 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));

                    P 1 Reply Last reply 25 Dec 2023, 18:40
                    0
                    • S StudentScripter
                      25 Dec 2023, 18:21

                      @Christian-Ehrlicher

                      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/
                      521d63ec-ae00-487e-927a-336196f37a57-image.png
                      abb1062a-5d6c-444e-b0bf-5721d574e85c-image.png 5d54f32f-4c99-4935-aa8f-1fa7cb34406c-image.png 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));

                      P Online
                      P Online
                      Pl45m4
                      wrote on 25 Dec 2023, 18:40 last edited by
                      #10

                      @StudentScripter

                      Have you tried to use -D QUAZIP_USE_QT_ZLIB=ON before you install zlib?


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      S 1 Reply Last reply 25 Dec 2023, 18:59
                      0
                      • P Pl45m4
                        25 Dec 2023, 18:40

                        @StudentScripter

                        Have you tried to use -D QUAZIP_USE_QT_ZLIB=ON before you install zlib?

                        S Offline
                        S Offline
                        StudentScripter
                        wrote on 25 Dec 2023, 18:59 last edited by
                        #11

                        @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. 0df1e194-6266-4cb2-8105-c4c2e1f391d6-image.png
                        284b1be4-525e-4597-ab3b-7b3154f9d080-image.png

                        quazip.pro file looks like this:
                        i added zlib.h to the project headder files aswell as zconf.h
                        d8412535-1e5e-4dfa-a692-5f0f148048f0-image.png

                        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 +=
                        
                        
                        S 1 Reply Last reply 25 Dec 2023, 19:21
                        0
                        • S StudentScripter
                          25 Dec 2023, 18:59

                          @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. 0df1e194-6266-4cb2-8105-c4c2e1f391d6-image.png
                          284b1be4-525e-4597-ab3b-7b3154f9d080-image.png

                          quazip.pro file looks like this:
                          i added zlib.h to the project headder files aswell as zconf.h
                          d8412535-1e5e-4dfa-a692-5f0f148048f0-image.png

                          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 +=
                          
                          
                          S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 25 Dec 2023, 19:21 last edited by
                          #12

                          @StudentScripter Which version are you trying to build ?

                          The latest code uses CMake as build system and what you show is using qmake.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          S 1 Reply Last reply 26 Dec 2023, 09:21
                          0
                          • S SGaist
                            25 Dec 2023, 19:21

                            @StudentScripter Which version are you trying to build ?

                            The latest code uses CMake as build system and what you show is using qmake.

                            S Offline
                            S Offline
                            StudentScripter
                            wrote on 26 Dec 2023, 09:21 last edited by StudentScripter
                            #13

                            @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

                            C 1 Reply Last reply 26 Dec 2023, 09:38
                            0
                            • S StudentScripter
                              26 Dec 2023, 09:21

                              @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

                              C Offline
                              C Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on 26 Dec 2023, 09:38 last edited by
                              #14

                              You should use the latest version and not some ancient ones: https://github.com/stachenov/quazip/releases

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              S 1 Reply Last reply 26 Dec 2023, 10:38
                              0
                              • C Christian Ehrlicher
                                26 Dec 2023, 09:38

                                You should use the latest version and not some ancient ones: https://github.com/stachenov/quazip/releases

                                S Offline
                                S Offline
                                StudentScripter
                                wrote on 26 Dec 2023, 10:38 last edited by
                                #15

                                @Christian-Ehrlicher

                                1. I downloaded QuaZip v1.4 and unzipped it

                                2. I downloaded zlib (the precompiled dll and source code from here: http://www.winimage.com/zLibDll/)

                                3. I copyied the zlibwapi.dll, zlib_bor.lib, zlibwapi.lib to an extra folder:
                                  ebb7f06b-9967-4850-9a58-eecd6705170c-image.png

                                4. I took the zlib.h and zconf.h from the source files and copied it into the quazip folder:
                                  34ec6bf4-1a5f-4ecd-92d3-487afd8a1322-image.png

                                5) What to do next? Or should i do something different?

                                S 1 Reply Last reply 26 Dec 2023, 12:11
                                0
                                • S StudentScripter
                                  26 Dec 2023, 10:38

                                  @Christian-Ehrlicher

                                  1. I downloaded QuaZip v1.4 and unzipped it

                                  2. I downloaded zlib (the precompiled dll and source code from here: http://www.winimage.com/zLibDll/)

                                  3. I copyied the zlibwapi.dll, zlib_bor.lib, zlibwapi.lib to an extra folder:
                                    ebb7f06b-9967-4850-9a58-eecd6705170c-image.png

                                  4. I took the zlib.h and zconf.h from the source files and copied it into the quazip folder:
                                    34ec6bf4-1a5f-4ecd-92d3-487afd8a1322-image.png

                                  5) What to do next? Or should i do something different?

                                  S Offline
                                  S Offline
                                  StudentScripter
                                  wrote on 26 Dec 2023, 12:11 last edited by
                                  #16

                                  @Christian-Ehrlicher @SGaist I simply opened the cmake file inside the quazip folder with qt: e73a18d1-850e-4c46-9373-8f42d66536e1-image.png

                                  i tried adding the paths to my library and includes as mentioned the post above but no luck, build is grayed out... f686fcc5-9ec9-4b36-94e7-b050d153bfbf-image.png

                                  # 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()
                                  
                                  
                                  S 1 Reply Last reply 27 Dec 2023, 08:21
                                  0
                                  • S StudentScripter
                                    26 Dec 2023, 12:11

                                    @Christian-Ehrlicher @SGaist I simply opened the cmake file inside the quazip folder with qt: e73a18d1-850e-4c46-9373-8f42d66536e1-image.png

                                    i tried adding the paths to my library and includes as mentioned the post above but no luck, build is grayed out... f686fcc5-9ec9-4b36-94e7-b050d153bfbf-image.png

                                    # 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()
                                    
                                    
                                    S Offline
                                    S Offline
                                    StudentScripter
                                    wrote on 27 Dec 2023, 08:21 last edited by
                                    #17

                                    bumping this

                                    C 1 Reply Last reply 27 Dec 2023, 08:33
                                    0
                                    • S StudentScripter
                                      27 Dec 2023, 08:21

                                      bumping this

                                      C Offline
                                      C Offline
                                      Christian Ehrlicher
                                      Lifetime Qt Champion
                                      wrote on 27 Dec 2023, 08:33 last edited by
                                      #18

                                      @StudentScripter since you do not follow the official documentation no more comments from me anymore...

                                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                                      Visit the Qt Academy at https://academy.qt.io/catalog

                                      S 1 Reply Last reply 27 Dec 2023, 08:52
                                      0
                                      • C Christian Ehrlicher
                                        27 Dec 2023, 08:33

                                        @StudentScripter since you do not follow the official documentation no more comments from me anymore...

                                        S Offline
                                        S Offline
                                        StudentScripter
                                        wrote on 27 Dec 2023, 08:52 last edited by StudentScripter
                                        #19

                                        @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:
                                        98845edf-9d8e-45ba-a944-60d1dba021a5-image.png
                                        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
                                        
                                        1 Reply Last reply
                                        0

                                        2/19

                                        23 Dec 2023, 15:13

                                        topic:navigator.unread, 17
                                        • Login

                                        • Login or register to search.
                                        2 out of 19
                                        • First post
                                          2/19
                                          Last post
                                        0
                                        • Categories
                                        • Recent
                                        • Tags
                                        • Popular
                                        • Users
                                        • Groups
                                        • Search
                                        • Get Qt Extensions
                                        • Unsolved