Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Ada LZMA Library Binding

Build Status License GitLab Download

This is a small Ada05 library binding for the liblzma library.

About liblzma

liblzma is a public domain general-purpose data compression library with a zlib-like API.

liblzma is part of XZ Utils XZ Utils includes a gzip-like command line tool named xz and some other tools. XZ Utils is developed and maintained by Lasse Collin.

Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK

Building ada-lzma

Before you build the package you must install the liblzma library. The installation of liblzma depends on your system:

System Install with
Ubuntu & Debian sudo apt-get install liblzma-dev
Fedora sudo yum install xz-devel
NetBSD pre installed (contrib/xz)
FreeBSD pre installed (contrib/xz)
Windows See
Source See

Build with the following commands:



The installation is done with gprinstall if the configure script found it or by traditional copy. In all cases, you should install with the next command:

make install

How to use Ada LZMA

Two examples are provided to illustrate how to use the library. Look at these examples for the details on how to use some of the operations.

samples/compress_easy.adb is an example on how to compress some stream. samples/decompress.adb shows hoz to decompress a stream.

Roughly speaking, import some package:

with Lzma.Base;
with Lzma.Container;
with Lzma.Check;

Then declare the LZMA stream:

Stream  : aliased Lzma.Base.lzma_stream := Lzma.Base.LZMA_STREAM_INIT;

Initialize the LZMA stream as decoder (or as encoder):

Result := Lzma.Container.lzma_stream_decoder (Stream'Unchecked_Access,

Setup the stream 'next_out', 'avail_out', 'next_in' and 'avail_in' and call the lzma_code operation with the action (Lzma.Base.LZMA_RUN or Lzma.Base.LZMA_FINISH):

Result := Lzma.Base.lzma_code (Stream'Unchecked_Access, Action);

Close the LZMA stream:

Lzma.Base.lzma_end (Stream'Unchecked_Access);