Skip Navigation Links
Skip Navigation LinksHome > ZipArchive > How to Use > Article
Compilation of the ZipArchive Library and Integration with Applications
Applies To: All

C++ Standard Support

The ZipArchive Library requires a C++98 compatible compiler. ZSTD support requires C++11 or later.

Compilation Preprocessor Directives

The file _platform.h contains preprocessor directives that control the compilation process under various platforms. You can alter the definition of these directives to produce the desired version of the ZipArchive Library.

STL / MFC

The ZipArchive Library by default compiles using STL. On Windows, you can optionally compile using MFC instead.

With CMake: Use the ZIP_USE_MFC option to control STL vs MFC:

  • -DZIP_USE_MFC=OFF - Use STL (default for all platforms, required for Linux/macOS)
  • -DZIP_USE_MFC=ON - Use MFC (Windows only)
    • CMake automatically sets CMAKE_MFC_FLAG based on the ZIP_RUNTIME_MULTITHREADED_DLL option
    • If ZIP_RUNTIME_MULTITHREADED_DLL=ON: Uses shared MFC DLL (defines _AFXDLL)
    • If ZIP_RUNTIME_MULTITHREADED_DLL=OFF: Uses static MFC library

Without CMake: Define _ZIP_IMPL_MFC to use MFC. If not defined, _ZIP_IMPL_STL will be automatically defined and the library will use STL.

Windows / Linux / macOS

The ZipArchive Library compiles for the current platform automatically.

With CMake: The platform is automatically detected and configured:

  • Linux/macOS builds: CMake automatically defines _ZIP_SYSTEM_LINUX
  • Windows builds: No special definition needed; Windows is the default platform
  • Platform-specific source files are automatically included based on the detected operating system
  • On Linux/macOS, threading support is automatically linked (Threads::Threads)
  • CMake presets are platform-aware and will only show presets for your current platform (e.g., linux-utf8 on Linux/macOS, windows-unicode-stl-md on Windows)

Without CMake: Define _ZIP_SYSTEM_LINUX for Linux/macOS platforms. If not defined, _ZIP_SYSTEM_WIN will be automatically defined and the library will compile for the Windows platform.

Endianness Detection

The ZipArchive Library supports both little-endian and big-endian architectures.

With CMake: Endianness is automatically detected using CMake's built-in TestBigEndian module. The appropriate _ZIP_BIG_ENDIAN definition is set automatically:

  • Little-endian systems: _ZIP_BIG_ENDIAN=0 (automatically detected)
  • Big-endian systems: _ZIP_BIG_ENDIAN=1 (automatically detected)

Manual Override: For cross-compilation or special cases, you can force a specific endianness using the ZIP_FORCE_ENDIAN option:

  • -DZIP_FORCE_ENDIAN=auto - Automatic detection (default)
  • -DZIP_FORCE_ENDIAN=big - Force big-endian
  • -DZIP_FORCE_ENDIAN=little - Force little-endian

Without CMake: The library attempts simple endianness detection at compile time. If detection fails or you need to override it, define _ZIP_BIG_ENDIAN in your build configuration:

  • Define _ZIP_BIG_ENDIAN=1 for big-endian architectures
  • Do not define it (or set to 0) for little-endian architectures (default)

Your Application Configuration

  • Make sure that your application compiles with the same macro definitions as the ZipArchive Library.
    • If you are using Windows MFC, make sure that your application defines _ZIP_IMPL_MFC.
    • If you are using Linux/macOS, make sure that your application defines _ZIP_SYSTEM_LINUX.
  • The ZipArchive Library MFC projects configurations already define _ZIP_IMPL_MFC. You only need to define them in your project settings.
  • To define these macros in your code, you can use one of the following methods:
    • use CMake files bundled with the library or define the macros in your CMake project files
    • define them in your code before including the ZipArchive.h file,
    • or define them globally in your project's settings:
      • VS 2017-2026
        • Project Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions
      • Linux/macOS
        • define them e.g. in your makefile
    • or adjust the _platform.h file directly. The defined directives in this file will be visible to both the ZipArchive Library and your application. This solution however has some disadvantages:
      • If you are using original ZipArchive projects (they already define _ZIP_IMPL_MFC or _ZIP_SYSTEM_LINUX), you may receive macro redefinition warning.
      • If you are compiling applications for different platforms from the same ZipArchive Library sources, you may experience recompilation of the ZipArchive Library that follows every _platform.h file modification.

Compilation and Integration

CMake

CMake is the preferred way to build the ZipArchive Library. It supports multiple platforms, compilers, and provides extensive configuration options through presets.

CMake projects are also supported by Visual Studio. The preferred version is Visual Studio 2019 version 16.10. See Microsoft's web site for more information.

Prerequisites

  • CMake 3.25 or later
  • C++ compiler (MSVC, GCC, Clang).

Using CMake Presets

The ZipArchive Library provides comprehensive CMake presets for easy configuration. Presets combine multiple options into named configurations.

List Available Presets:

List configure presets for your platform:
cmake --list-presets

On Linux/macOS, you'll see presets like:

  • linux-utf8 - Static library
  • linux-utf8-dll - Shared library

Configure Using a Preset:

Linux/macOS - Static library (most common):
cmake --preset linux-utf8

Windows - Static library, Unicode, STL, DLL Runtime:
cmake --preset windows-unicode-stl-md

Windows - Static library, Unicode, MFC, DLL Runtime:
cmake --preset windows-unicode-mfc-md

Override preset options (example: disable BZIP2):
cmake --preset linux-utf8 -DZIP_ENABLE_BZIP2=OFF

Build Using a Preset:

Build the configured preset:
cmake --build --preset linux-utf8

Build in Release mode (default is Debug):
cmake --build --preset linux-utf8 --config Release

Manual Configuration (Without Presets)

You can also configure manually by specifying a build directory and options:

Create and enter build directory:
mkdir build && cd build

Configure with options:
cmake .. \
  -DCMAKE_BUILD_TYPE=Release \
  -DZIP_ENABLE_UNICODE=ON \
  -DZIP_ENABLE_ZIP64=ON \
  -DZIP_ENABLE_AES=ON \
  -DZIP_ENABLE_BZIP2=ON \
  -DZIP_ENABLE_ZSTD=ON

Build:
cmake --build . --config Release

Install (optional):
sudo cmake --install .

Common CMake Options

Option Values Description
Build Options
BUILD_ZIPPIE ON/OFF Build command-line tool (default: OFF)
BUILD_ZIPARC ON/OFF Build MFC GUI app - Windows only (default: OFF)
ZIP_OUTPUT_NAME string Output library name (default: "ZipArchive")
ZIP_BUILD_SHARED ON/OFF Build shared library instead of static (default: OFF)
ZIP_BUILD_UNICODE ON/OFF Build with Unicode character support with UNICODE and _UNICODE macros defined (default: ON on Windows, OFF on Linux/macOS)
Feature Options
ZIP_ENABLE_ZIP64 ON/OFF Enable ZIP64 for files >4GB (default: ON)
ZIP_ENABLE_AES ON/OFF Enable WinZip AES encryption (default: ON)
ZIP_ENABLE_BZIP2 ON/OFF Enable BZIP2 compression (default: ON)
ZIP_USE_BZIP2_INTERNAL ON/OFF Use internal BZIP2 sources vs system library (default: ON on Windows, OFF on Linux/macOS)
ZIP_ENABLE_ZSTD ON/OFF Enable Zstandard compression (default: ON)
ZIP_USE_ZSTD_INTERNAL ON/OFF Use internal ZSTD sources vs system library (default: ON)
ZIP_ENABLE_SEEK ON/OFF Enable seekable data support (default: ON)
ZIP_ENABLE_UNICODE ON/OFF Enable Unicode support for filenames or comments - requires ZIP_BUILD_UNICODE on Windows (default: ON)
ZIP_ENABLE_USE_LOCKING ON/OFF Enable locking for multithreaded AES (default: ON)
ZIP_USE_HWAES ON/OFF Enable hardware AES acceleration (Intel AES-NI or ARM Crypto Extensions). Automatically detected at runtime and used when available. Provides ~8-14x speedup for AES encryption/decryption (default: ON)
ZIP_USE_HWCRC ON/OFF Enable hardware CRC-32 acceleration (Intel PCLMULQDQ or ARM CRC32 instructions). Automatically detected at runtime and used when available. Provides speedup for CRC-32 computation (default: ON)
ZIP_ENABLE_STRICT_U16 ON/OFF Use WORD types for index/volume numbers when ZIP64 is OFF (default: ON)
Platform Options
ZIP_USE_MFC ON/OFF Use MFC instead of STL - Windows only (default: OFF)
ZIP_RUNTIME_MULTITHREADED_DLL ON/OFF Use DLL runtime (/MD) vs static (/MT) - Windows only (default: ON)
ZIP_ARCHITECTURE native/x64/x86/arm64/universal Target architecture - Linux/macOS only (default: native)
ZIP_FORCE_ENDIAN auto/big/little Endianness detection/override (default: auto)
Optimization Options (Advanced)
ZIP_OPTIMIZE_MARCH string Target architecture for -march flag - Linux/macOS only (e.g., native, haswell, armv8.4-a). Leave empty for maximum compatibility (default: empty)
ZIP_OPTIMIZE_MTUNE string Target CPU for -mtune flag - Linux/macOS only (e.g., native, haswell, skylake). Leave empty for default tuning (default: empty)
ZIP_OPTIMIZE_ARCH string Target architecture for /arch flag - Windows only (e.g., AVX, AVX2, AVX512). Leave empty for default SSE2 on x64 (default: empty)
Windows Unicode Options (Advanced)
ZIP_ENABLE_UNICODE_CUSTOM ON/OFF Enable custom Unicode support - Windows only, deprecated, requires ZIP_BUILD_UNICODE (default: OFF)
ZIP_ENABLE_UNICODE_NORMALIZE ON/OFF Enable Unicode normalization for macOS archives - Windows only, requires ZIP_BUILD_UNICODE (default: OFF)
Other Options
ZIP_USE_ZLIB_NG ON/OFF Use zlib-ng instead of bundled zlib (requires zlib-ng in ZipArchive directory)(default: OFF)

Optimizing for Performance

The ZipArchive Library can achieve better compression and decompression performance when compiled with architecture-specific optimizations. This is especially beneficial for AES, ZSTD compression and CRC32.

Performance Improvements:

  • AES encryption/decryption: Intel AES-NI or ARM Crypto Extensions - enabled by default via ZIP_USE_HWAES=ON
  • ZSTD compression/decompression: BMI2 instructions
  • CRC-32 computation: Intel PCLMULQDQ or ARM CRC32 instructions - enabled by default via ZIP_USE_HWCRC=ON
  • .
  • Release builds: Automatically use /Ox (Windows) or -O3 (Linux/macOS) for maximum optimization

Recommended Settings by Platform:

Windows (MSVC): Enable AVX2 for BMI2 support
cmake --preset windows-unicode-stl-md -DZIP_OPTIMIZE_ARCH=AVX2
cmake --build --preset windows-unicode-stl-md --config Release

Note: AVX2 requires Intel Haswell (2013+) or AMD Excavator (2015+) processors.

Linux/macOS (x86-64): Use Haswell architecture for BMI2 support
cmake --preset linux-utf8 -DZIP_OPTIMIZE_MARCH=haswell
cmake --build --preset linux-utf8 --config Release

Note: The binary will only run on CPUs from 2013 or newer. For maximum compatibility, omit the -DZIP_OPTIMIZE_MARCH option.

Apple Silicon (ARM): Optimize for ARM architecture
cmake --preset linux-utf8 -DZIP_OPTIMIZE_MARCH=armv8.4-a+crc+crypto
cmake --build --preset linux-utf8 --config Release

Note: ARM Crypto Extensions and CRC32 instructions are always available on Apple Silicon and automatically used for AES and CRC-32 acceleration when ZIP_USE_HWAES=ON and ZIP_USE_HWCRC=ON (default). For other ARM platforms, the +crc flag enables compile-time CRC-32 optimizations.

Maximum Performance (Build Machine Only):
# Linux/macOS
cmake --preset linux-utf8 -DZIP_OPTIMIZE_MARCH=native
cmake --build --preset linux-utf8 --config Release

# Windows
cmake --preset windows-unicode-stl-md -DZIP_OPTIMIZE_ARCH=AVX2
cmake --build --preset windows-unicode-stl-md --config Release

Warning: Using -march=native creates binaries optimized for your specific CPU. They may not run on older or different processors.

Compatibility vs Performance Trade-off:

  • Maximum Compatibility: Don't set any optimization flags (default) - runs on all CPUs but slower
  • Balanced: Use -march=haswell or /arch:AVX2 - good performance, works on most modern CPUs (2013+)
  • Maximum Performance: Use -march=native - best performance, only runs on the build machine's CPU or newer

Windows-Specific Configuration

On Windows, you can choose the runtime library and MFC configuration:

Static runtime (/MT), STL, Unicode:
cmake --preset windows-unicode-stl-mt

DLL runtime (/MD), MFC, Unicode:
cmake --preset windows-unicode-mfc-md

Or specify architecture with -A:
cmake -A x64 -B build -DZIP_ENABLE_UNICODE=ON
cmake --build build --config Release

Cross-Platform Architecture Builds

macOS - Build for Apple Silicon:
cmake --preset linux-utf8 -DZIP_ARCHITECTURE=arm64

macOS - Build universal binary (x64 + arm64):
cmake --preset linux-utf8 -DZIP_ARCHITECTURE=universal

Linux - Build 32-bit on 64-bit system:
cmake --preset linux-utf8 -DZIP_ARCHITECTURE=x86

Installing the Library

After building with a preset, install the library system-wide using the preset name.

Linux/macOS: Build and install to default location (/usr/local)

cmake --preset linux-utf8
cmake --build --preset linux-utf8 --config Release
sudo cmake --install build/linux-utf8

Install to custom location:
cmake --install build/linux-utf8 --prefix /opt/ziparchive

Windows: Build and install to default location (C:\Program Files\)

cmake --preset windows-unicode-stl-md
cmake --build --preset windows-unicode-stl-md --config Release
cmake --install build\windows-unicode-stl-md

Install to custom location:
cmake --install build\windows-unicode-stl-md --prefix "C:\ZipArchive"

Uninstalling the Library

The ZipArchive Library includes a convenient uninstall target that removes all installed files. This feature requires that you've previously installed the library, as it relies on the install_manifest.txt file created during installation.

Uninstalling with CMake Presets:

Linux/macOS:
sudo cmake --build build/linux-utf8 --target uninstall

Windows:
cmake --build build/windows-unicode-stl-md --target uninstall

Uninstalling without Presets:

From your build directory:
cd build
sudo cmake --build . --target uninstall

Important Notes:

  • The uninstall target only works if you've run the install command first
  • The install_manifest.txt file must exist in your build directory
  • On Linux/macOS, use sudo when uninstalling from system directories
  • If you installed to a custom prefix, uninstall will remove files from that location

Using ZipArchive in Your CMake Project

After installing, integrate ZipArchive into your CMake project. In your CMakeLists.txt:

cmake_minimum_required(VERSION 3.25)
project(MyApp)

find_package(ZipArchive REQUIRED)

add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE ZipArchive::ZipArchive)

CMake will automatically handle all include paths and compiler definitions (Unicode, platform, etc.).

Common Issues

  • Preset not found: Make sure you're in the project root directory where CMakePresets.json exists
  • Architecture mismatch: On Windows, use -A x64 or -A Win32 instead of ZIP_ARCHITECTURE

Microsoft Visual Studio

The project files can be found in the _projects folder in the library distribution sources package. By default, the most recent project files are copied to the source code folders. To add the ZipArchive Library functionality to your application, you need to link the library with it. You can do it e.g. with one of the following methods. In both cases you need to include ZipArchive.h header in your sources.

Integration Method 1 (Simpler)

Add your application project and the ZipArchive Library project to the same solution/workspace and:
  • VS 2017-2026
    • Set your project to reference the ZipArchive Library project (on the Solution Explorer, either: right click your project, select References... from the menu and add the library or - depending on the version - click Add Reference...) on the References node.
When you use this method, the configurations in both your project and the ZipArchive Library project should match. Optimally, the configurations should have the same names.

Integration Method 2

  • Add ZipArchive.lib to
    • VS 2017-2026
      • Project Properties -> Linker -> Input -> Additional Dependencies
  • Set the proper directories, so that Visual Studio can find the library and its headers. You can do this locally (for the current project only), or globally (for all projects):
    • To add the directories locally:
      • Add the ZipArchive.lib directory to:
        • VS 2017-2026
          • Project Properties -> Linker -> General -> Additional Library Directories
      • Add the ZipArchive Library source code directory to the preprocessor searches
        • VS 2017-2026
          • Project Properties -> C/C++ -> General -> Additional include directories
    • To add the directories globally, add them into appropriate places (Include Files and Library Files) in:
      • VS 2017-2026
        • Project Properties -> VC++ Directories

Choosing STL/MFC Configurations

The Visual Studio projects provided with the ZipArchive Library already include appropriate preprocessor definitions for STL/MFC compilations.
  • VS 2017-2026
    • To compile the STL version, use configurations that include STL in its names.
    • To compile the MFC version, use configurations that do not include STL in its names.

64-bit Compilation

  • VS 2017-2026
    • As from 4.6.4 version, x64 configurations are provided in the library projects.
    • Open Configuration Manager (Build -> Configuration Manager...).
    • In the Active solution platform select <New...>.
    • Select x64 platfrom in the Type or select the new platform field.
    • Keep Copy settings from set to Win32 and Create new project platforms checked.
    • Click OK.
    • Ensure x64 is selected in the Active solution platform drop down and you can now compile for x64.
  • Your project should use the MFC library and the Runtime Library in same way as the ZipArchive Library project. This can be set in:
    • VS 2017-2026
      • Project Properties -> General -> Use of MFC
      • Project Properties -> C/C++ -> Code Generation -> Runtime library
  • If you are compiling for Unicode, make sure that you have installed the necessary libraries. During installation you need to select Static Libraries for Unicode and Shared Libraries for Unicode. They are located in:
    • VS 2017-2026
      • Not needed.
    You don't need to reinstall Visual Studio to add these libraries, just modify the installation.
  • You should use the same character set in both your project and the ZipArchive Library project. This can be set in:
    • VS 2017-2026
      • Project Properties -> General -> Character Set
  • Treat wchar_t as Built-in Type option should be set to the same value in your application project and in the ZipArchive Project. This option can be found in:
    • VS 2017-2026
      • Project Properties -> C/C++ -> Language -> Treat WChar_t as Built-in Type
    This value is set by default to:
    • VS 2017-2026 - Yes or True.
    When compiling a project that uses the ZipArchive Library and Qt it may be required to set this value to False.
  • When you create a new project configuration or modify an existing one that uses (or was using before your modification) MFC, you may experience some problems coming from the order that Visual Studio links libraries. This results in link errors saying that some symbols are already defined in a different library. In link errors you will probably see two libraries mentioned, such as mfcs80.lib and MSVCRT.lib. The libraries will differ depending on other settings. You may correct the order of linking in the following way:
    • Ignore both libraries in project's settings:
      • VS 2017-2026
        • Project Properties -> Linker -> Input -> Ignore Specific Default Libraries
    • Add both libraries in the correct order in project's settings. The CRT library should go first (in the example above, this would be the MSVCRT.lib file.
      • VS 2017-2026
        • Project Properties -> Linker -> Input -> Additional Dependencies
    The ZipArchive Library projects already define the correct linking order in some places, but if you change some settings (such as use of MFC, Runtime Library or Unicode), you will need to adjust the above settings. Also, if you will change the project settings to not use MFC, you will probably want to clear those settings.
  • If you experience linking problems with projects that use ATL, you can try the following:
    • Try using MD configurations when dynamically linking to ATL and MT configurations when statically linking to ATL.
    • You may need to adjust the order of linking libraries as described above.
    • If you are using MFC, you may need to remove any using namespace declarations for ATL namespaces.
    • Try including ZipArchive.h file in a top level header, e.g. in stdafx.h.

Additional Considerations

  • [Visual Studio 2005-2026 only] When you deploy your project on a computer that does not have the related Visual Studio version installed, you may experience exceptions being thrown by your application that come from the fact that it cannot find correct libraries. In this case, you will probably need to install Microsoft Visual C++ Redistributable Package on the client machine depending with which version of Visual Studio the project was compiled. Make sure that you use the correct version of the package. There are versions for different platforms (x86, x64, IA64) and they depend on the service pack you have installed on your Visual Studio.

C++Builder and Borland

To compile the library under C++Builder, create e.g. a Static Library project, add source files to it and compile. If you receive an error during linking saying that [TLib Error] library too large, please restart with library page size 32. , increase the Page Size value in the Project Options on the "TLib" page. A value of 128 should be sufficient.

iOS

The ZipArchive Library can be compiled for iOS using e.g. the following steps (appropriate for XCode 4):
  • Create a new C/C++ Library project for macOS (available under File -> New -> Project -> macOS -> Framework & Library -> C/C++ Library).
  • Click Next.
  • Ensure the Type is set to Static, update other data as needed and finish creation of the project.
  • In the project's build settings, set Base SDK to Latest iOS.
  • Set Architectures to Standard.
  • Verify that Build Active Architecture Only and Valid Architectures suit your needs (sometimes, you may want to add e.g. i386 architecture).
  • Verify that the active scheme is set correctly (to iOS Device or a simulator).
  • In the Preprocessor Macros section define macros to appropriate for your compilation. Unless you already defined them in the source code, normally, you will need to include there:
    • _ZIP_SYSTEM_LINUX=1
    • _ZIP_BZIP2_INTERNAL=1
    • _ZIP_ZSTD_INTERNAL=1
  • Build the project.

CZipFile Implementations

The functionality described in this paragraph is usually handled automatically by the ZipArchive Library. There are three implementations of the CZipFile class (responsible for file operations in the library):

  • STL - uses STL libraries for file operation. Used for the STL version of the library.
  • MFC - uses MFC libraries for file operation. Used for the MFC version of the library.
  • Windows API - uses Windows API directly for file operations. Used under Microsoft Visual Studio 6.0 (MFC) and C++Builder, because the libraries under these compilers do not support large files.

With CMake: The file implementation is automatically selected based on the ZIP_USE_MFC option:

  • ZIP_USE_MFC=OFF (default) - Uses STL implementation
  • ZIP_USE_MFC=ON (Windows only) - Uses MFC implementation
  • CMake automatically sets the appropriate _ZIP_IMPL_MFC or _ZIP_IMPL_STL definition. The Windows API implementation is automatically used for legacy compilers when needed.

Without CMake: You can adjust the file implementation behavior manually by setting the _ZIP_FILE_IMPLEMENTATION definition in the _features.h file to the following values:

  • ZIP_ZFI_DEFAULT - to use default implementation.
  • ZIP_ZFI_STL - to use STL implementation (possible with all versions of the library).
  • ZIP_ZFI_WIN - to use Windows API implementation (possible with all versions of the library, but only under Windows).
  • The reason MFC implementation cannot be defined explicitly is that it can be used only with the MFC version of the library.

Integrating with C++/CLI applications

The Library can be used in a C++/CLI application. You can follow the steps below to create a simple CLR application (under Visual Studio 2005-2026):
  • Create a new C++ CLR Console Application
  • Add the ZipArchive Library project to the solution
  • Add a reference to the ZipArchive Library project in the sample application project (on the Solution Explorer, click References... and add the ZipArchive Library project)
  • Include the ZipArchive.h header file. To avoid linking errors, you should place the include in the stdafx.h file.
  • Compile the Debug Unicode STL MD or Release Unicode STL MD configuration. Use /clr switch.
  • If you receive link errors, you can try reordering of headers inclusions in the stdafx.h file.

Compiling as Shared or Static Library

CMake

Control DLL support using the ZIP_BUILD_SHARED option:

  • Set -DZIP_BUILD_SHARED=ON to build as a shared library (default)
  • Set -DZIP_BUILD_SHARED=OFF to build as a static library

Windows

  • Your application that uses the ZipArchive Library as the DLL version needs to have ZIP_HAS_DLL defined. The ZipArchive.dll must be accessible for your application at the runtime. You can put it in your application's executable directory.
  • The ZipArchive Library project configuration that compiles the DLL version needs to have ZIP_HAS_DLL and ZIP_BUILD_DLL defined.

Linux

On some systems (m68k and the SPARC), when you want to compile the ZipArchive Library for the dynamic linking, you need to add -fPIC to CFLAGS.

UNC Paths and Very Long Paths (Windows Only)

To use the functionality described in this section, it is required to compile the ZipArchive Library in Unicode mode and use CZipFile implementation to use Windows API (see above).
  • ZipArchive Library automatically includes the neccessary long path prefix when needed.
  • To manually prefix the paths:
    • To use long UNC paths, replace \\ at the beginning of the UNC path with \\?\UNC\ ("\\\\?\\UNC\\" when escaped).
    • To use long file paths (not limited to 260 characters for file paths and 248 characters for folder paths) include \\?\ at the beginning of each path ("\\\\?\\" when escaped). Paths are limited to 32,767 characters in this case.

Using Zlib-ng Instead of Bundled zlib

zlib-ng is a modernized fork of zlib that offers improved performance and additional features. The ZipArchive Library can be configured to use zlib-ng instead of the bundled zlib for deflate compression and decompression tasks.

To use zlib-ng instead of the bundled zlib, you need to:
  • Clone zlib-ng source code inside the ZipArchive directory (beside the zlib folder)
  • Add the following lines to zlib_name_mangling.h.in: #define z_stream         @ZLIB_SYMBOL_PREFIX@z_stream#define deflate_state    @ZLIB_SYMBOL_PREFIX@deflate_state
  • If you want to support large files with Zip64, modify manually total_out and total_in fields in the z_stream_s structure definition to be of unsigned long long type. The structure definition is located in the zlib-ng/zutil.h.in file near to the top.
  • Configure the ZipArchive Library to use zlib-ng instead of zlib by following the steps below.

With CMake (recommended): Set the ZIP_USE_ZLIB_NG option to ON when configuring the project, for example, cmake --preset linux-utf8 -DZIP_USE_ZLIB_NG=ON

Without CMake: It requires manual compilation of zlib-ng and including it in a ZipArchive project. Then, define the ZIP_USE_ZLIB_NG_BUILD macro before including the ZipArchive headers and when compiling the library to enable zlib-ng support.

Article ID: 0610050933
Back To Top Up