Compilation of the ZipArchive Library and Integration with Applications
Applies To: All

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. If you wish to compile the library using MFC, make sure that _ZIP_IMPL_MFC is defined. If it is not defined, _ZIP_IMPL_STL will be automatically defined and the library will use STL.

Windows / Linux / OS X

The ZipArchive Library by default compiles for the Windows platform. If you wish to compile the library for the Linux/Mac OS X platform, make sure that _ZIP_SYSTEM_LINUX is defined. If it is not defined, _ZIP_SYSTEM_WIN will be automatically defined and the library will compile for the Windows platform.

Endianess Detection

The ZipArchive Library can work on little-endian and big-endian architectures. It tries a simple detection of the current architecture, but you may need to adjust it. By default, the library compiles for a little-endian architecture. Define _ZIP_BIG_ENDIAN to compile the library for a big-endian architecture.

Your Application Configuration

Compilation and Integration

The ZipArchive Library uses Microsoft Visual Studio C++ 2010 project files by default. To compile under a different environment, copy the appropriate project files to the ZipArchive Library sources folder. The project files can be found in the _projects folder in the library distribution sources package.

Microsoft Visual Studio

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: 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

Choosing STL/MFC Configurations

The Visual Studio projects provided with the ZipArchive Library already include appropriate preprocessor definitions for STL/MFC compilations.

64-bit Compilation

Additional Considerations

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.

Linux/OS X

The ZipArchive Library does not use the Zlib library that is installed in the system. The Zlib library included in the ZipArchive Library is slightly modified for its needs.

iOS

The ZipArchive Library can be compiled for iOS using e.g. the following steps (appropriate for XCode 4):

MinGW

You can compile the ZipArchive Library using the provided Makefile.mingw file under both the MSYS shell and the Windows Command Line.

Additional Considerations

CMake

It's possible to compile the ZipArchive Library using CMake, but the necessary macro definitions need to be included in the config file, e.g.:

IF((MSVC))
set_property(
TARGET ZipArchive
PROPERTY COMPILE_DEFINITIONS _USRDLL ZIP_BUILD_DLL ZIP_HAS_DLL
NO_DUMMY_DECL _CRT_RAND_S
)
ENDIF((MSVC))

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): If you need, you can adjust this behavior by setting the _ZIP_FILE_IMPLEMENTATION definition in the _features.h file to the following values: 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 2022/2019/2017/2015/2013/2012/2010/2008/2005):

Compiling as DLL

Windows

Linux

On some systems (m68k and the SPARC), when you want to compile the ZipArchive Library for the dynamic linking, you need to modify makefile files (for the Zlib and ZipArchive) so that CFLAGS definition includes -fPIC.

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).
Article ID: 0610050933
Copyright © 2000 - 2022 Artpol Software - Tadeusz Dracz