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. Installing/Compiling QuaZip for Qt6 and Windows with CMake? Here is how!

Installing/Compiling QuaZip for Qt6 and Windows with CMake? Here is how!

Scheduled Pinned Locked Moved General and Desktop
quazipqt6windows10c++cmake
12 Posts 6 Posters 4.7k 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 30 Dec 2023, 11:45 last edited by StudentScripter
    #1

    Do you struggle with getting QuaZip or Zlib installed on windows? Found no good tutorials and the official documentation doesn't work either? I've been there and here i how i fixed it.

    [Been using Qt6, Windows 10, C++17 Standard, MinGW, Cmake 3.27.0, ZLib 1.3, QuaZip 1.4]

    1) Installing and building Zlib:

    1. Download Zlib source code from the official website (don't take the precompiled dll, we will build from source) http://www.winimage.com/zLibDll/

    2. Unpack the .zip package in a folder on your desktop

    3. Open cmd. (run as administrator) and enter the following (replace with your path):

    cd C:/Ur/PATH/TO/zlib-1.3
    
    mkdir build
    
    cd build
    
    1. Your path inside the cmd console should look something like this: C:/Users/YOURNAME/Desktop/YourFolder/zlib-1.3.

    2. Now make a second folder where you want your final compiled library want to be, copy the path and enter this in the cmd:

    cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=<YOUR FINAL INSTALL PATH>
    
    cmake --build . --config Release
    
    cmake --install . --config Release
    
    1. Congratulations you now should have build zlib. To use it in your Qt project simply
      #include "Zlib.h"

    and in your cmake file of qt project:
    include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
    link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
    target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)

    .
    .
    Here is my minimal cmake file:
    #REMOVE THE ------>

    cmake_minimum_required(VERSION 3.5)
    
    project(ZlibTest VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
    
    ------>   include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
    l----->   link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
    
    set(PROJECT_SOURCES
            main.cpp
            MainWindow.cpp
            MainWindow.h
            MainWindow.ui
    )
    
    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        qt_add_executable(ZlibTest
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
        )
    else()
        if(ANDROID)
            add_library(ZlibTest SHARED
                ${PROJECT_SOURCES}
            )
        else()
            add_executable(ZlibTest
                ${PROJECT_SOURCES}
            )
        endif()
    endif()
    
    
    
    # Fügen Sie diese Zeile hinzu, um zlib zu Ihrem Projekt zu verlinken
    ------->  target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)
    
    
    

    .
    .

    As we have zlib installed we are now able to build QuaZip.

    2) Installing and building QuaZip:

    1. As with zlib install QuaZip from github, choose the newest version, download the zip and unpack it inside a folder on your desktop: https://github.com/stachenov/quazip

    2. (DO and Come back to this 2nd step only if your getting errors when building with the standard cmake file.)
      (2.) Go into the quazip master file and find the cmake file there, open it with an editor:
      replace it with this:

    # 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" "")
      #option(ZLIB_LIBRARY "Path to library dir" "")
      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 COMPONENTS Core REQUIRED)
    find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
    if (Qt${QT_VERSION_MAJOR}_FOUND)
        get_filename_component(QT_HOME "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE)
        message(STATUS "Found Qt ${QT_VERSION}: ${QT_HOME}")
    else()
        message(FATAL_ERROR "Couldn't find Qt")
    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)
      # Name of the Zlib component has been changed in 6.3.1
      if(Qt6_VERSION VERSION_GREATER_EQUAL "6.3.1")
        set(QUAZIP_QT_ZLIB_COMPONENT BundledZLIB)
      else()
        set(QUAZIP_QT_ZLIB_COMPONENT Zlib)
      endif()
    	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_QT_ZLIB_COMPONENT Zlib)
    	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_QT_ZLIB_COMPONENT Zlib)
    	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 ${QUAZIP_QT_ZLIB_COMPONENT})
        if(Qt${QUAZIP_QT_MAJOR_VERSION}${QUAZIP_QT_ZLIB_COMPONENT}_FOUND)
            set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::${QUAZIP_QT_ZLIB_COMPONENT})
            set(QUAZIP_QT_ZLIB_USED ON)
        endif()
    endif()
    
    if(QUAZIP_QT_ZLIB_USED AND QUAZIP_QT_ZLIB_COMPONENT STREQUAL BundledZLIB)
      # Qt's new BundledZLIB uses z-prefix in zlib
      add_compile_definitions(Z_PREFIX)
    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()
    
    
    1. Now same as with zlib: open cmd as administrator, copy the path to your quazip master file:
    cd C:/Ur/PATH/TO/zlib-1.3
    
    mkdir build
    
    cd build
    
    1. Now we provide all necessary paths manually as there was an error at the time where none of the dependencys where found. We do it by entering this into cmd:
    cmake -G "MinGW Makefiles" -S .. -B . -DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake" -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include"
    

    EXPLANATION:
    DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" = create a new folder where you want the final library to be installed

    -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake
    = Your path where your qt6conf.cmake file is located you have to find that yourself

    -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" = Path to your zlib.lib file

    -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include" =Path to the include folder of your zlib

    1. With that everything should have run smooth and we now can finally build QuaZip by entering into cmd:
    cmake --build . --target install
    

    Hope this helps someone. Also thanks to @veryqtperson who helped me to figure that out.

    PS: I really hate it when people around here just say "RTFM" - "read the f*cking manual" as i did that but the manuals instruction just did NOT work, even after trying multiple times. So yeah may consider that before writing your next post. We are all just humans and make mistakes. Stay friendly and help each other. :)

    veryqtpersonV 1 Reply Last reply 30 Dec 2023, 12:37
    0
    • S StudentScripter marked this topic as a regular topic on 30 Dec 2023, 12:16
    • S StudentScripter
      30 Dec 2023, 11:45

      Do you struggle with getting QuaZip or Zlib installed on windows? Found no good tutorials and the official documentation doesn't work either? I've been there and here i how i fixed it.

      [Been using Qt6, Windows 10, C++17 Standard, MinGW, Cmake 3.27.0, ZLib 1.3, QuaZip 1.4]

      1) Installing and building Zlib:

      1. Download Zlib source code from the official website (don't take the precompiled dll, we will build from source) http://www.winimage.com/zLibDll/

      2. Unpack the .zip package in a folder on your desktop

      3. Open cmd. (run as administrator) and enter the following (replace with your path):

      cd C:/Ur/PATH/TO/zlib-1.3
      
      mkdir build
      
      cd build
      
      1. Your path inside the cmd console should look something like this: C:/Users/YOURNAME/Desktop/YourFolder/zlib-1.3.

      2. Now make a second folder where you want your final compiled library want to be, copy the path and enter this in the cmd:

      cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=<YOUR FINAL INSTALL PATH>
      
      cmake --build . --config Release
      
      cmake --install . --config Release
      
      1. Congratulations you now should have build zlib. To use it in your Qt project simply
        #include "Zlib.h"

      and in your cmake file of qt project:
      include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
      link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
      target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)

      .
      .
      Here is my minimal cmake file:
      #REMOVE THE ------>

      cmake_minimum_required(VERSION 3.5)
      
      project(ZlibTest VERSION 0.1 LANGUAGES CXX)
      
      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)
      
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
      find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
      
      ------>   include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
      l----->   link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
      
      set(PROJECT_SOURCES
              main.cpp
              MainWindow.cpp
              MainWindow.h
              MainWindow.ui
      )
      
      if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
          qt_add_executable(ZlibTest
              MANUAL_FINALIZATION
              ${PROJECT_SOURCES}
          )
      else()
          if(ANDROID)
              add_library(ZlibTest SHARED
                  ${PROJECT_SOURCES}
              )
          else()
              add_executable(ZlibTest
                  ${PROJECT_SOURCES}
              )
          endif()
      endif()
      
      
      
      # Fügen Sie diese Zeile hinzu, um zlib zu Ihrem Projekt zu verlinken
      ------->  target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)
      
      
      

      .
      .

      As we have zlib installed we are now able to build QuaZip.

      2) Installing and building QuaZip:

      1. As with zlib install QuaZip from github, choose the newest version, download the zip and unpack it inside a folder on your desktop: https://github.com/stachenov/quazip

      2. (DO and Come back to this 2nd step only if your getting errors when building with the standard cmake file.)
        (2.) Go into the quazip master file and find the cmake file there, open it with an editor:
        replace it with this:

      # 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" "")
        #option(ZLIB_LIBRARY "Path to library dir" "")
        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 COMPONENTS Core REQUIRED)
      find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
      if (Qt${QT_VERSION_MAJOR}_FOUND)
          get_filename_component(QT_HOME "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE)
          message(STATUS "Found Qt ${QT_VERSION}: ${QT_HOME}")
      else()
          message(FATAL_ERROR "Couldn't find Qt")
      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)
        # Name of the Zlib component has been changed in 6.3.1
        if(Qt6_VERSION VERSION_GREATER_EQUAL "6.3.1")
          set(QUAZIP_QT_ZLIB_COMPONENT BundledZLIB)
        else()
          set(QUAZIP_QT_ZLIB_COMPONENT Zlib)
        endif()
      	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_QT_ZLIB_COMPONENT Zlib)
      	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_QT_ZLIB_COMPONENT Zlib)
      	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 ${QUAZIP_QT_ZLIB_COMPONENT})
          if(Qt${QUAZIP_QT_MAJOR_VERSION}${QUAZIP_QT_ZLIB_COMPONENT}_FOUND)
              set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::${QUAZIP_QT_ZLIB_COMPONENT})
              set(QUAZIP_QT_ZLIB_USED ON)
          endif()
      endif()
      
      if(QUAZIP_QT_ZLIB_USED AND QUAZIP_QT_ZLIB_COMPONENT STREQUAL BundledZLIB)
        # Qt's new BundledZLIB uses z-prefix in zlib
        add_compile_definitions(Z_PREFIX)
      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()
      
      
      1. Now same as with zlib: open cmd as administrator, copy the path to your quazip master file:
      cd C:/Ur/PATH/TO/zlib-1.3
      
      mkdir build
      
      cd build
      
      1. Now we provide all necessary paths manually as there was an error at the time where none of the dependencys where found. We do it by entering this into cmd:
      cmake -G "MinGW Makefiles" -S .. -B . -DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake" -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include"
      

      EXPLANATION:
      DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" = create a new folder where you want the final library to be installed

      -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake
      = Your path where your qt6conf.cmake file is located you have to find that yourself

      -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" = Path to your zlib.lib file

      -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include" =Path to the include folder of your zlib

      1. With that everything should have run smooth and we now can finally build QuaZip by entering into cmd:
      cmake --build . --target install
      

      Hope this helps someone. Also thanks to @veryqtperson who helped me to figure that out.

      PS: I really hate it when people around here just say "RTFM" - "read the f*cking manual" as i did that but the manuals instruction just did NOT work, even after trying multiple times. So yeah may consider that before writing your next post. We are all just humans and make mistakes. Stay friendly and help each other. :)

      veryqtpersonV Offline
      veryqtpersonV Offline
      veryqtperson
      wrote on 30 Dec 2023, 12:37 last edited by veryqtperson
      #2

      Download Zlib source code from the official website [...] http://www.winimage.com/zLibDll/

      That isn't the official zlib weibsite. This one is.

      To use it [...] simply #include "Zlib.h"

      In the original file name Z is not capital. And it should be <> here, include, not "".

      include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
      link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")

      There are better ways of adding zlib into one's project.

      -G "MinGW Makefiles"

      Not sure many would want to use this generator. And you haven't provided an explanation why you did.

      There are other items in your instructions, which I wouldn't recommend others to pick up. Moreover, I see no point in it really, as it doesn't add any actually new/valuable information, in my opinion. If anything, it should've been probably posted in your original thread instead of creating a new topic.

      Overall, I'm afraid, you really should have RTFMed. As I said earlier, all this stuff (almost) just works out of the box.

      S 1 Reply Last reply 30 Dec 2023, 13:40
      0
      • veryqtpersonV veryqtperson
        30 Dec 2023, 12:37

        Download Zlib source code from the official website [...] http://www.winimage.com/zLibDll/

        That isn't the official zlib weibsite. This one is.

        To use it [...] simply #include "Zlib.h"

        In the original file name Z is not capital. And it should be <> here, include, not "".

        include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
        link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")

        There are better ways of adding zlib into one's project.

        -G "MinGW Makefiles"

        Not sure many would want to use this generator. And you haven't provided an explanation why you did.

        There are other items in your instructions, which I wouldn't recommend others to pick up. Moreover, I see no point in it really, as it doesn't add any actually new/valuable information, in my opinion. If anything, it should've been probably posted in your original thread instead of creating a new topic.

        Overall, I'm afraid, you really should have RTFMed. As I said earlier, all this stuff (almost) just works out of the box.

        S Offline
        S Offline
        StudentScripter
        wrote on 30 Dec 2023, 13:40 last edited by
        #3

        @veryqtperson Well you're right it should be indeed #include <zlib.h>, also gonna correct the link to official zlib site. The link i pasted first was from their related external links. Also gonna update the way of how to actually include zlib in project.

        Regarding MinGW: could you please explain why you rather wouldn't wanna use it and what you would use instead? I myself have been building all my qt projects with MinGW so far, but had no problems with it.

        For me it didn't work out of the box and therefore i created this thread to may help others who struggle like myself.
        In my case neither zlib nor qt6conf.cmake where found by the original cmake file provided with QuaZip. And as it seems on their github other users have been experiencing similar problems.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          StudentScripter
          wrote on 30 Dec 2023, 14:00 last edited by
          #4

          Do you struggle with getting QuaZip or Zlib installed on windows? Found no good tutorials and the official documentation doesn't work either? I've been there and here i how i fixed it.

          [Been using Qt6, Windows 10, C++17 Standard, MinGW, Cmake 3.27.0, ZLib 1.3, QuaZip 1.4]

          1) Installing and building Zlib:

          1. Download Zlib source code from the official website (don't take the precompiled dll, we will build from source) https://www.zlib.net/

          2. Unpack the .zip package in a folder on your desktop

          3. Open cmd. (run as administrator) and enter the following (replace with your path):

          cd C:/Ur/PATH/TO/zlib-1.3
          
          mkdir build
          
          cd build
          
          1. Your path inside the cmd console should look something like this: C:/Users/YOURNAME/Desktop/YourFolder/zlib-1.3.

          2. Now make a second folder where you want your final compiled library want to be, copy the path and enter this in the cmd:

          cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=<YOUR FINAL INSTALL PATH>
          
          cmake --build . --config Release
          
          cmake --install . --config Release
          
          1. Congratulations you now should have build zlib. To use it in your Qt project simply
            #include <zlib.h>

          and in your cmake file of qt project:
          include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
          link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
          target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)

          .
          .
          Here is my minimal cmake file:
          #REMOVE THE ------>

          cmake_minimum_required(VERSION 3.5)
          
          project(ZlibTest VERSION 0.1 LANGUAGES CXX)
          
          set(CMAKE_AUTOUIC ON)
          set(CMAKE_AUTOMOC ON)
          set(CMAKE_AUTORCC ON)
          
          set(CMAKE_CXX_STANDARD 17)
          set(CMAKE_CXX_STANDARD_REQUIRED ON)
          
          find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
          find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
          
          ------>   include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
          l----->   link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
          
          set(PROJECT_SOURCES
                  main.cpp
                  MainWindow.cpp
                  MainWindow.h
                  MainWindow.ui
          )
          
          if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
              qt_add_executable(ZlibTest
                  MANUAL_FINALIZATION
                  ${PROJECT_SOURCES}
              )
          else()
              if(ANDROID)
                  add_library(ZlibTest SHARED
                      ${PROJECT_SOURCES}
                  )
              else()
                  add_executable(ZlibTest
                      ${PROJECT_SOURCES}
                  )
              endif()
          endif()
          
          
          
          # Add this line to link the libraries with your project
          ------->  target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)
          
          
          

          .
          .

          As we have zlib installed we are now able to build QuaZip.

          2) Installing and building QuaZip:

          1. As with zlib install QuaZip from github, choose the newest version, download the zip and unpack it inside a folder on your desktop: https://github.com/stachenov/quazip

          2. (DO and Come back to this 2nd step only if your getting errors when building with the standard cmake file.)
            (2.) Go into the quazip master file and find the cmake file there, open it with an editor:
            replace it with this:

          # 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" "")
            #option(ZLIB_LIBRARY "Path to library dir" "")
            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 COMPONENTS Core REQUIRED)
          find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
          if (Qt${QT_VERSION_MAJOR}_FOUND)
              get_filename_component(QT_HOME "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE)
              message(STATUS "Found Qt ${QT_VERSION}: ${QT_HOME}")
          else()
              message(FATAL_ERROR "Couldn't find Qt")
          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)
            # Name of the Zlib component has been changed in 6.3.1
            if(Qt6_VERSION VERSION_GREATER_EQUAL "6.3.1")
              set(QUAZIP_QT_ZLIB_COMPONENT BundledZLIB)
            else()
              set(QUAZIP_QT_ZLIB_COMPONENT Zlib)
            endif()
          	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_QT_ZLIB_COMPONENT Zlib)
          	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_QT_ZLIB_COMPONENT Zlib)
          	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 ${QUAZIP_QT_ZLIB_COMPONENT})
              if(Qt${QUAZIP_QT_MAJOR_VERSION}${QUAZIP_QT_ZLIB_COMPONENT}_FOUND)
                  set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::${QUAZIP_QT_ZLIB_COMPONENT})
                  set(QUAZIP_QT_ZLIB_USED ON)
              endif()
          endif()
          
          if(QUAZIP_QT_ZLIB_USED AND QUAZIP_QT_ZLIB_COMPONENT STREQUAL BundledZLIB)
            # Qt's new BundledZLIB uses z-prefix in zlib
            add_compile_definitions(Z_PREFIX)
          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()
          
          
          1. Now same as with zlib: open cmd as administrator, copy the path to your quazip master file:
          cd C:/Ur/PATH/TO/zlib-1.3
          
          mkdir build
          
          cd build
          
          1. Now we provide all necessary paths manually as there was an error at the time where none of the dependencys where found. We do it by entering this into cmd:
          cmake -G "MinGW Makefiles" -S .. -B . -DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake" -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include"
          

          EXPLANATION:
          DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" = create a new folder where you want the final library to be installed

          -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake
          = Your path where your qt6conf.cmake file is located you have to find that yourself

          -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" = Path to your zlib.lib file

          -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include" =Path to the include folder of your zlib

          1. With that everything should have run smooth and we now can finally build QuaZip by entering into cmd:
          cmake --build . --target install
          

          Hope this helps someone. Also thanks to @veryqtperson who helped me to figure that out.

          PS: We are all just humans and make mistakes. Stay friendly and help each other. :)

          D 1 Reply Last reply 6 Feb 2024, 22:34
          0
          • S Offline
            S Offline
            StudentScripter
            wrote on 30 Dec 2023, 15:13 last edited by StudentScripter
            #5

            This is how the final minimal cmake file looks (please keep in mind to disable bzip2 support in the cmake config of QuaZip before building, else you will get bzip2 missing errors):

            cmake_minimum_required(VERSION 3.5)
            
            project(ZlibTest VERSION 0.1 LANGUAGES CXX)
            
            set(CMAKE_AUTOUIC ON)
            set(CMAKE_AUTOMOC ON)
            set(CMAKE_AUTORCC ON)
            
            set(CMAKE_CXX_STANDARD 17)
            set(CMAKE_CXX_STANDARD_REQUIRED ON)
            
            
            
            find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
            find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
            
            
            
            list(APPEND CMAKE_PREFIX_PATH "C:/Users/YOURNAME/QtLibraryBuilds/ZlibLibrary/lib")
            list(APPEND CMAKE_PREFIX_PATH "C:/Users/YOURNAME/QtLibraryBuilds/ZlibLibrary/include")
            
            find_package(ZLIB REQUIRED)
            
            # Fügen Sie diese Pfade dem Include-Verzeichnis und den Link-Verzeichnissen hinzu
            include_directories(${ZLIB_INCLUDE_DIR})
            link_directories(${ZLIB_LIBRARY})
            
            
            list(APPEND CMAKE_PREFIX_PATH "C:/Users/YOURNAME/QtLibraryBuilds/QuaZipLibrary/lib/cmake/QuaZip-Qt6-1.4")
            
            
            # Laden Sie QuaZip und verknüpfen Sie es mit Ihrem Projekt
            find_package(QuaZip-Qt6 REQUIRED)
            include_directories(${QuaZip-Qt6_INCLUDE_DIR})
            
            
            
            
            
            
            
            set(PROJECT_SOURCES
                    main.cpp
                    MainWindow.cpp
                    MainWindow.h
                    MainWindow.ui
            )
            
            if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                qt_add_executable(ZlibTest
                    MANUAL_FINALIZATION
                    ${PROJECT_SOURCES}
                )
            else()
                if(ANDROID)
                    add_library(ZlibTest SHARED
                        ${PROJECT_SOURCES}
                    )
                else()
                    add_executable(ZlibTest
                        ${PROJECT_SOURCES}
                    )
                endif()
            endif()
            
            
            
            target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ZLIB::ZLIB QuaZip::QuaZip)
            
            
            
            
            
            
            
            if(${QT_VERSION} VERSION_LESS 6.1.0)
              set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ZlibTest)
            endif()
            set_target_properties(ZlibTest PROPERTIES
                ${BUNDLE_ID_OPTION}
                MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
                MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
                MACOSX_BUNDLE TRUE
                WIN32_EXECUTABLE TRUE
            )
            
            include(GNUInstallDirs)
            install(TARGETS ZlibTest
                BUNDLE DESTINATION .
                LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
                RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
            )
            
            if(QT_VERSION_MAJOR EQUAL 6)
                qt_finalize_executable(ZlibTest)
            endif()
            
            
            1 Reply Last reply
            0
            • S StudentScripter
              30 Dec 2023, 14:00

              Do you struggle with getting QuaZip or Zlib installed on windows? Found no good tutorials and the official documentation doesn't work either? I've been there and here i how i fixed it.

              [Been using Qt6, Windows 10, C++17 Standard, MinGW, Cmake 3.27.0, ZLib 1.3, QuaZip 1.4]

              1) Installing and building Zlib:

              1. Download Zlib source code from the official website (don't take the precompiled dll, we will build from source) https://www.zlib.net/

              2. Unpack the .zip package in a folder on your desktop

              3. Open cmd. (run as administrator) and enter the following (replace with your path):

              cd C:/Ur/PATH/TO/zlib-1.3
              
              mkdir build
              
              cd build
              
              1. Your path inside the cmd console should look something like this: C:/Users/YOURNAME/Desktop/YourFolder/zlib-1.3.

              2. Now make a second folder where you want your final compiled library want to be, copy the path and enter this in the cmd:

              cmake -S .. -B . -DCMAKE_INSTALL_PREFIX=<YOUR FINAL INSTALL PATH>
              
              cmake --build . --config Release
              
              cmake --install . --config Release
              
              1. Congratulations you now should have build zlib. To use it in your Qt project simply
                #include <zlib.h>

              and in your cmake file of qt project:
              include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
              link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
              target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)

              .
              .
              Here is my minimal cmake file:
              #REMOVE THE ------>

              cmake_minimum_required(VERSION 3.5)
              
              project(ZlibTest VERSION 0.1 LANGUAGES CXX)
              
              set(CMAKE_AUTOUIC ON)
              set(CMAKE_AUTOMOC ON)
              set(CMAKE_AUTORCC ON)
              
              set(CMAKE_CXX_STANDARD 17)
              set(CMAKE_CXX_STANDARD_REQUIRED ON)
              
              find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
              find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
              
              ------>   include_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/include")
              l----->   link_directories("C:/Users/YOU/PATH/TO/FINAL/LIBRARY/lib")
              
              set(PROJECT_SOURCES
                      main.cpp
                      MainWindow.cpp
                      MainWindow.h
                      MainWindow.ui
              )
              
              if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                  qt_add_executable(ZlibTest
                      MANUAL_FINALIZATION
                      ${PROJECT_SOURCES}
                  )
              else()
                  if(ANDROID)
                      add_library(ZlibTest SHARED
                          ${PROJECT_SOURCES}
                      )
                  else()
                      add_executable(ZlibTest
                          ${PROJECT_SOURCES}
                      )
                  endif()
              endif()
              
              
              
              # Add this line to link the libraries with your project
              ------->  target_link_libraries(ZlibTest PRIVATE Qt${QT_VERSION_MAJOR}::Widgets zlib)
              
              
              

              .
              .

              As we have zlib installed we are now able to build QuaZip.

              2) Installing and building QuaZip:

              1. As with zlib install QuaZip from github, choose the newest version, download the zip and unpack it inside a folder on your desktop: https://github.com/stachenov/quazip

              2. (DO and Come back to this 2nd step only if your getting errors when building with the standard cmake file.)
                (2.) Go into the quazip master file and find the cmake file there, open it with an editor:
                replace it with this:

              # 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" "")
                #option(ZLIB_LIBRARY "Path to library dir" "")
                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 COMPONENTS Core REQUIRED)
              find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
              if (Qt${QT_VERSION_MAJOR}_FOUND)
                  get_filename_component(QT_HOME "${Qt${QT_VERSION_MAJOR}_DIR}/../../.." ABSOLUTE)
                  message(STATUS "Found Qt ${QT_VERSION}: ${QT_HOME}")
              else()
                  message(FATAL_ERROR "Couldn't find Qt")
              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)
                # Name of the Zlib component has been changed in 6.3.1
                if(Qt6_VERSION VERSION_GREATER_EQUAL "6.3.1")
                  set(QUAZIP_QT_ZLIB_COMPONENT BundledZLIB)
                else()
                  set(QUAZIP_QT_ZLIB_COMPONENT Zlib)
                endif()
              	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_QT_ZLIB_COMPONENT Zlib)
              	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_QT_ZLIB_COMPONENT Zlib)
              	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 ${QUAZIP_QT_ZLIB_COMPONENT})
                  if(Qt${QUAZIP_QT_MAJOR_VERSION}${QUAZIP_QT_ZLIB_COMPONENT}_FOUND)
                      set(QUAZIP_LIB_LIBRARIES ${QUAZIP_LIB_LIBRARIES} Qt${QUAZIP_QT_MAJOR_VERSION}::${QUAZIP_QT_ZLIB_COMPONENT})
                      set(QUAZIP_QT_ZLIB_USED ON)
                  endif()
              endif()
              
              if(QUAZIP_QT_ZLIB_USED AND QUAZIP_QT_ZLIB_COMPONENT STREQUAL BundledZLIB)
                # Qt's new BundledZLIB uses z-prefix in zlib
                add_compile_definitions(Z_PREFIX)
              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()
              
              
              1. Now same as with zlib: open cmd as administrator, copy the path to your quazip master file:
              cd C:/Ur/PATH/TO/zlib-1.3
              
              mkdir build
              
              cd build
              
              1. Now we provide all necessary paths manually as there was an error at the time where none of the dependencys where found. We do it by entering this into cmd:
              cmake -G "MinGW Makefiles" -S .. -B . -DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake" -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include"
              

              EXPLANATION:
              DCMAKE_INSTALL_PREFIX="C:/Users/YOU/QtLibraryBuilds/QuaZipLibrary" = create a new folder where you want the final library to be installed

              -DCMAKE_PREFIX_PATH="C:\Users\YOU\Documents\Qt\6.5.2\mingw_64\lib\cmake
              = Your path where your qt6conf.cmake file is located you have to find that yourself

              -DZLIB_LIBRARY:FILEPATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/lib/zlib.lib" = Path to your zlib.lib file

              -DZLIB_INCLUDE_DIR:PATH="C:/Users/YOU/QtLibraryBuilds/ZlibLibrary/include" =Path to the include folder of your zlib

              1. With that everything should have run smooth and we now can finally build QuaZip by entering into cmd:
              cmake --build . --target install
              

              Hope this helps someone. Also thanks to @veryqtperson who helped me to figure that out.

              PS: We are all just humans and make mistakes. Stay friendly and help each other. :)

              D Offline
              D Offline
              Dorgham
              wrote on 6 Feb 2024, 22:34 last edited by Dorgham 2 Jun 2024, 22:56
              #6

              @StudentScripter I do not have CMake file for QT project (in its folder) and there is no MinGW in Qt\6.5.3 folder (for me) since I am using msvc2019_64, so how to replace it? I am new to this stuff, so I am not understanding well. Thank you for your effort!

              1 Reply Last reply
              0
              • A apaczenko1993 referenced this topic on 10 Apr 2024, 13:41
              • TheGabmeisterT Offline
                TheGabmeisterT Offline
                TheGabmeister
                wrote on 15 Jul 2024, 07:22 last edited by
                #7

                Thanks for this guide. In case someone here encounters the following Core5Compat error:

                -- Could NOT find Qt6Core5Compat (missing: Qt6Core5Compat_DIR)
                CMake Error at CMakeLists.txt:39 (find_package):
                  Found package configuration file:
                
                    C:/Qt/6.7.2/mingw_64/lib/cmake/Qt6/Qt6Config.cmake
                
                  but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
                  FOUND.  Reason given by package:
                
                  Failed to find required Qt component "Core5Compat".
                
                  Expected Config file at
                  "C:/Qt/6.7.2/mingw_64/lib/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake"
                  does NOT exist
                

                Just install the Qt 5 Compatibility Module from the MaintenanceTool as explained in this other thread.

                S 1 Reply Last reply 23 Jul 2024, 16:02
                0
                • TheGabmeisterT TheGabmeister
                  15 Jul 2024, 07:22

                  Thanks for this guide. In case someone here encounters the following Core5Compat error:

                  -- Could NOT find Qt6Core5Compat (missing: Qt6Core5Compat_DIR)
                  CMake Error at CMakeLists.txt:39 (find_package):
                    Found package configuration file:
                  
                      C:/Qt/6.7.2/mingw_64/lib/cmake/Qt6/Qt6Config.cmake
                  
                    but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
                    FOUND.  Reason given by package:
                  
                    Failed to find required Qt component "Core5Compat".
                  
                    Expected Config file at
                    "C:/Qt/6.7.2/mingw_64/lib/cmake/Qt6Core5Compat/Qt6Core5CompatConfig.cmake"
                    does NOT exist
                  

                  Just install the Qt 5 Compatibility Module from the MaintenanceTool as explained in this other thread.

                  S Offline
                  S Offline
                  StudentScripter
                  wrote on 23 Jul 2024, 16:02 last edited by
                  #8

                  @TheGabmeister Glad it helped, it may not be a very good or perfect guide but glad someone else could profit. :) It was a pain for me back than and took me so long to get it working somehow.

                  1 Reply Last reply
                  0
                  • TheGabmeisterT Offline
                    TheGabmeisterT Offline
                    TheGabmeister
                    wrote on 26 Jul 2024, 07:40 last edited by
                    #9

                    I encountered another error. The above steps work fine in QT Creator. I tested it both in x64 Debug and Release, and I was able to extract a .zip file. However, when I tried deploying the .exe and preparing the .dll dependencies, I discovered that quazip1-qt6.dll has a dependency with x86 zlib.dll. This is preventing the .exe from running.

                    Here is the screenshot from Dependency Walker showing quazip1-qt6.dll x64 having a dependency with zlib.dll x86:
                    zlib-x86.png

                    I am not sure why this is happening. I tried building zlib and QuaZip several times, tried both MinGW and MSVC, used x64 Release mode, double checked ZLIB_LIBRARY and ZLIB_INCLUDE_DIR are correct, double checked my zlib.dll using dumpbin and it is indeed x64, but nothing worked. I still get this odd dependency. I have read that it's possible that there is another zlib.dll existing somewhere in my computer. Perhaps Qt itself depends on zlib.dll x86? Or another application? If so, how do I make sure that quazip1-qt6.dll will depend on the zlib.dll x64 version, not x86?

                    My setup:
                    Windows 11
                    Qt Creator 13.0.2 (Community)
                    Qt 6.7.2
                    MSVC 2019 64-bit (I also tried MinGW 11.2.0 64-bit)
                    CMake 3.30.0
                    zlib 1.3.1 and QuaZip 1.4

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on 26 Jul 2024, 07:49 last edited by
                      #10

                      Your assumption is wrong. You simply did not deliver a zlib.dll and so another one somewhere in the PATH is picked up which is 32bit.

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

                      TheGabmeisterT 1 Reply Last reply 26 Jul 2024, 13:07
                      3
                      • Christian EhrlicherC Christian Ehrlicher
                        26 Jul 2024, 07:49

                        Your assumption is wrong. You simply did not deliver a zlib.dll and so another one somewhere in the PATH is picked up which is 32bit.

                        TheGabmeisterT Offline
                        TheGabmeisterT Offline
                        TheGabmeister
                        wrote on 26 Jul 2024, 13:07 last edited by
                        #11

                        Oh wow, thank you. All I needed to do was copy x64 zlib.dll to the same directory as the .exe. The answer was right in front of me all this time.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Susu_69
                          wrote on 23 Aug 2024, 14:12 last edited by
                          #12

                          hey that is really helpful but
                          i want to ask can some one guide me building Quazip and Zlib by Qt creator in build Cmake
                          i don't want to download separate Cmake and perform all these commands in it
                          i tried to do this and i guess i was partially succesfull

                          i got this Msg in my application output while running Zlib
                          zlib version 1.3.1 = 0x1310, compile flags = 0x65
                          uncompress(): hello, hello!
                          gzread(): hello, hello!
                          gzgets() after gzseek: hello!
                          inflate(): hello, hello!
                          large_inflate(): OK
                          after inflateSync(): hello, hello!
                          inflate with dictionary: hello, hello!

                          and i found these files in my build folder = libzlib.dll
                          libzlib.dll.a
                          and other files
                          but when i tried to build Quazip it did not gone as planed i got so many errors
                          so can someone pls give its answer too i really appreciate that.

                          1 Reply Last reply
                          0

                          • Login

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