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. Problems with QuaZip
Forum Updated to NodeBB v4.3 + New Features

Problems with QuaZip

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 7.5k Views 1 Watching
  • 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.
  • K Offline
    K Offline
    Kamba
    wrote on last edited by
    #1

    Hey, I'm making program where I need to unzip a .zip file. I found that QuaZip is library for it and it's crossplatform(I need it for windows and linux). I'm working on linux machine, but code should also compile on windows machine.

    The problem is that I don't know how to set it up. If I understood it right, QuaZip depends on Zlib and it needs zconf.h and zlib.h files from Zlib to work.

    So I made quazip folder in my project folder which contains these files:
    http://imgur.com/nGU9Lsz

    In .pro file i added following lines:

    HEADERS += $$PWD/quazip/*.h
    SOURCES += $$PWD/quazip/*.cpp
    SOURCES += $$PWD/quazip/*.c
    

    I have included JlCompress.h like this in file where i need it:

    #include "quazip/JlCompress.h"
    

    and tried to use it like this:

    JlCompress *asd;
    asd->extractDir(filepath, destinationDir);
    

    but I get these errors:

    :-1: error: quaziodevice.o: undefined reference to symbol 'deflate'
    
    /usr/lib/libz.so.1:-1: error: error adding symbols: DSO missing from command line
    
    :-1: error: collect2: error: ld returned 1 exit status
    

    Could you help me please?

    raven-worxR 1 Reply Last reply
    0
    • K Kamba

      Hey, I'm making program where I need to unzip a .zip file. I found that QuaZip is library for it and it's crossplatform(I need it for windows and linux). I'm working on linux machine, but code should also compile on windows machine.

      The problem is that I don't know how to set it up. If I understood it right, QuaZip depends on Zlib and it needs zconf.h and zlib.h files from Zlib to work.

      So I made quazip folder in my project folder which contains these files:
      http://imgur.com/nGU9Lsz

      In .pro file i added following lines:

      HEADERS += $$PWD/quazip/*.h
      SOURCES += $$PWD/quazip/*.cpp
      SOURCES += $$PWD/quazip/*.c
      

      I have included JlCompress.h like this in file where i need it:

      #include "quazip/JlCompress.h"
      

      and tried to use it like this:

      JlCompress *asd;
      asd->extractDir(filepath, destinationDir);
      

      but I get these errors:

      :-1: error: quaziodevice.o: undefined reference to symbol 'deflate'
      
      /usr/lib/libz.so.1:-1: error: error adding symbols: DSO missing from command line
      
      :-1: error: collect2: error: ld returned 1 exit status
      

      Could you help me please?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Kamba said:

      /usr/lib/libz.so.1:-1: error: error adding symbols: DSO missing from command line

      see this.
      This should also solve your first error.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • K Offline
        K Offline
        Kamba
        wrote on last edited by
        #3

        I added

        unix {
            LIBS += -L$$PWD/quazip -lz
        }
        

        to .pro file and now it compiles, but I guess it works because I have Zlib package installed on my machine. Installed Zlib package from repository shouldn't be a problem.
        What should I write for windows in:

        win32 {
         
        }
        

        I guess I need to add zlib1.dll, zdll.lib and zlib.def to quazip folder, so program can find Zlib?
        I tried to add them there and wrote in .pro file:

        win32 {
            LIBS += -L$$PWD/quazip -lzdll
        }
        

        but now I get a lot of warnings like

        QString, QString)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
         bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) {
              ^
        

        and errors like

        error: undefined reference to `_imp___ZN10JlCompress10extractDirE7QStringS0_'
        
        raven-worxR 1 Reply Last reply
        0
        • K Kamba

          I added

          unix {
              LIBS += -L$$PWD/quazip -lz
          }
          

          to .pro file and now it compiles, but I guess it works because I have Zlib package installed on my machine. Installed Zlib package from repository shouldn't be a problem.
          What should I write for windows in:

          win32 {
           
          }
          

          I guess I need to add zlib1.dll, zdll.lib and zlib.def to quazip folder, so program can find Zlib?
          I tried to add them there and wrote in .pro file:

          win32 {
              LIBS += -L$$PWD/quazip -lzdll
          }
          

          but now I get a lot of warnings like

          QString, QString)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
           bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) {
                ^
          

          and errors like

          error: undefined reference to `_imp___ZN10JlCompress10extractDirE7QStringS0_'
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @Kamba
          did you compile zlib on windows yourself?
          AFAIK this should be a C library. So i dont see why you should get dllimport related errors?

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kamba
            wrote on last edited by
            #5

            Files (zdll.lib, zlib.def and zlib1.dll) are from pre compiled dll package from Zlib's website.
            Atm quazip folder looks like this http://imgur.com/nkFeqSc
            And .pro file has this for windows

            win32 {
                LIBS += -L$$PWD/quazip -lzdll
            }
            

            W7 64bit, QT 5.6

            kshegunovK 1 Reply Last reply
            0
            • K Kamba

              Files (zdll.lib, zlib.def and zlib1.dll) are from pre compiled dll package from Zlib's website.
              Atm quazip folder looks like this http://imgur.com/nkFeqSc
              And .pro file has this for windows

              win32 {
                  LIBS += -L$$PWD/quazip -lzdll
              }
              

              W7 64bit, QT 5.6

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by kshegunov
              #6

              @Kamba
              What compiler was used to compile that library and what compiler are you using?

              QString, QString)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
              bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) {
                   ^
              

              This looks like a problem @koahnig was recently tackling, see here. The cause finally was discovered to be sources sneaking into the application code from the library.

              error: undefined reference to `_imp___ZN10JlCompress10extractDirE7QStringS0_'
              

              That's the linker complaining that your symbol can't be found.

              @raven-worx

              AFAIK this should be a C library. So i dont see why you should get dllimport related errors?

              C libraries export symbols exactly the same way as C++ libraries do. The only difference is that C++ symbol names are decorated.

              Kind regards.

              Read and abide by the Qt Code of Conduct

              K 1 Reply Last reply
              0
              • kshegunovK kshegunov

                @Kamba
                What compiler was used to compile that library and what compiler are you using?

                QString, QString)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
                bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) {
                     ^
                

                This looks like a problem @koahnig was recently tackling, see here. The cause finally was discovered to be sources sneaking into the application code from the library.

                error: undefined reference to `_imp___ZN10JlCompress10extractDirE7QStringS0_'
                

                That's the linker complaining that your symbol can't be found.

                @raven-worx

                AFAIK this should be a C library. So i dont see why you should get dllimport related errors?

                C libraries export symbols exactly the same way as C++ libraries do. The only difference is that C++ symbol names are decorated.

                Kind regards.

                K Offline
                K Offline
                Kamba
                wrote on last edited by
                #7

                @kshegunov said:

                @Kamba
                What compiler was used to compile that library and what compiler are you using?

                QString, QString)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
                bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) {
                     ^
                

                This problem occurs on windows with MinGW 32bit.

                kshegunovK 1 Reply Last reply
                0
                • K Kamba

                  @kshegunov said:

                  @Kamba
                  What compiler was used to compile that library and what compiler are you using?

                  QString, QString)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
                  bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) {
                       ^
                  

                  This problem occurs on windows with MinGW 32bit.

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #8

                  @Kamba
                  This was a question consisting of two parts, and you answered only half of it. Is the library you're trying to link against compiled with 32bit MinGW?
                  Forget that, it's irrelevant as zlib is a C library.

                  HEADERS += $PWD/quazip/*.h
                  SOURCES += $PWD/quazip/*.cpp
                  SOURCES += $PWD/quazip/*.c
                  

                  So instead of building quazip as a library as it was intended, you're just inserting source. It's not going to work like that. Build quazip separately, and then link it to your project.

                  Read and abide by the Qt Code of Conduct

                  K 1 Reply Last reply
                  0
                  • kshegunovK kshegunov

                    @Kamba
                    This was a question consisting of two parts, and you answered only half of it. Is the library you're trying to link against compiled with 32bit MinGW?
                    Forget that, it's irrelevant as zlib is a C library.

                    HEADERS += $PWD/quazip/*.h
                    SOURCES += $PWD/quazip/*.cpp
                    SOURCES += $PWD/quazip/*.c
                    

                    So instead of building quazip as a library as it was intended, you're just inserting source. It's not going to work like that. Build quazip separately, and then link it to your project.

                    K Offline
                    K Offline
                    Kamba
                    wrote on last edited by
                    #9

                    @kshegunov
                    Zlib? I don't know what compiler Zlib devs were using when they compiled it. I downloaded compiled dlls.
                    http://zlib.net/zlib128-dll.zip
                    I could try to compile it by myself from this
                    http://zlib.net/zlib128.zip

                    kshegunovK 1 Reply Last reply
                    0
                    • K Kamba

                      @kshegunov
                      Zlib? I don't know what compiler Zlib devs were using when they compiled it. I downloaded compiled dlls.
                      http://zlib.net/zlib128-dll.zip
                      I could try to compile it by myself from this
                      http://zlib.net/zlib128.zip

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by
                      #10

                      @Kamba

                      Zlib? I don't know what compiler Zlib devs were using when they compiled it. I downloaded compiled dlls.

                      Yes, and it doesn't matter. It's my bad, sorry and we cross posted.
                      You should follow the instructions for building the library given on quazip's site, though.

                      Read and abide by the Qt Code of Conduct

                      K 1 Reply Last reply
                      0
                      • kshegunovK kshegunov

                        @Kamba

                        Zlib? I don't know what compiler Zlib devs were using when they compiled it. I downloaded compiled dlls.

                        Yes, and it doesn't matter. It's my bad, sorry and we cross posted.
                        You should follow the instructions for building the library given on quazip's site, though.

                        K Offline
                        K Offline
                        Kamba
                        wrote on last edited by
                        #11

                        @kshegunov said:

                        @Kamba

                        Zlib? I don't know what compiler Zlib devs were using when they compiled it. I downloaded compiled dlls.

                        Yes, and it doesn't matter. It's my bad, sorry and we cross posted.
                        You should follow the instructions for building the library given on quazip's site, though.

                        But how it is working on linux then if the problem is in quazip?
                        I'm going to try building quazip on windows. Should I also do same for linux? Then I don't need to include sources in the project right?

                        kshegunovK 1 Reply Last reply
                        0
                        • K Kamba

                          @kshegunov said:

                          @Kamba

                          Zlib? I don't know what compiler Zlib devs were using when they compiled it. I downloaded compiled dlls.

                          Yes, and it doesn't matter. It's my bad, sorry and we cross posted.
                          You should follow the instructions for building the library given on quazip's site, though.

                          But how it is working on linux then if the problem is in quazip?
                          I'm going to try building quazip on windows. Should I also do same for linux? Then I don't need to include sources in the project right?

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on last edited by kshegunov
                          #12

                          @Kamba

                          But how it is working on linux then if the problem is in quazip?

                          On Linux Q_DECL_EXPORT expands to nothing, because there, the symbols are exported by default. On Windows it expands to __declspec(...) depending on whether it's import or export. The compiler and/or linker doesn't like this declaration specifier to be repeated and will not handle conflicts involving it very gracefully.

                          Basically, when you include the headers from the library you're telling the linker to import the symbol. But that symbol is nowhere to be found (as you don't have the quazip library at all) and the linker is confused ... it doesn't know where to get it, so you get the undefined references error.

                          I'm going to try building quazip on windows. Should I also do same for linux? Then I don't need to include sources in the project right?

                          Yes, you do the same for linux.
                          Yes, you don't include sources in the project.

                          Kind regards.

                          Read and abide by the Qt Code of Conduct

                          1 Reply Last reply
                          1
                          • K Offline
                            K Offline
                            Kamba
                            wrote on last edited by
                            #13

                            Now I got it working. Built QuaZip on windows and linux.
                            added to .pro file

                            INCLUDEPATH += $$PWD/quazip
                            LIBS += -L$$PWD/libs/ -lz
                            LIBS += -L$$PWD/libs/ -lquazip
                            

                            In quazip folder I have headers of Quazip. In libs folder I have .a files for windows and .so files for linux.
                            Including quazip for extracting works.

                            #include "quazip/JlCompress.h"
                            

                            This setup is working on both platforms. So I guess this is it?

                            kshegunovK 1 Reply Last reply
                            1
                            • K Kamba

                              Now I got it working. Built QuaZip on windows and linux.
                              added to .pro file

                              INCLUDEPATH += $$PWD/quazip
                              LIBS += -L$$PWD/libs/ -lz
                              LIBS += -L$$PWD/libs/ -lquazip
                              

                              In quazip folder I have headers of Quazip. In libs folder I have .a files for windows and .so files for linux.
                              Including quazip for extracting works.

                              #include "quazip/JlCompress.h"
                              

                              This setup is working on both platforms. So I guess this is it?

                              kshegunovK Offline
                              kshegunovK Offline
                              kshegunov
                              Moderators
                              wrote on last edited by
                              #14

                              @Kamba said:

                              So I guess this is it?

                              Indeed, this is it.
                              Cheers!

                              Read and abide by the Qt Code of Conduct

                              1 Reply Last reply
                              1

                              • Login

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