Prerequisites to Build libavif from Source
Building libavif from source allows you to compile the
latest version of the AVIF image format library with customized
configurations. This article outlines the essential compiler tools,
build systems, and codec dependencies required to successfully compile
libavif on your operating system.
Core Build Tools and Compilers
To compile the libavif library, you need a standard C
development environment and a build file generator.
- CMake (Version 3.13 or higher):
libavifuses CMake to configure the build environment and generate makefiles or project files. - C Compiler (C99 compliant):
- Linux/macOS: GCC or Clang.
- Windows: Visual Studio (MSVC) 2017 or newer.
- Build System:
- Ninja (highly recommended for fast builds) or GNU Make.
AV1 Codec Libraries
libavif is a wrapper library; it requires at least one
external AV1 encoder or decoder library to actually compress or
decompress images. You must install or compile at least one of the
following:
- aom (libaom): The alliance reference codec. It functions as both an encoder and decoder and is the most commonly used default dependency.
- dav1d: A highly optimized AV1 decoder, recommended if you only need to decode/read AVIF files.
- SVT-AV1: A high-performance AV1 encoder developed by Intel, ideal for fast encoding.
- rav1e: An AV1 encoder written in Rust, focusing on safety and speed.
During the CMake configuration step, you will need to point
libavif to the installation paths of these chosen
codecs.
Optional Tool Dependencies
If you plan to build the bundled command-line
tools—avifenc (encoder) and avifdec
(decoder)—you will need additional libraries to handle input and output
image formats:
- libpng: Required to convert PNG files to and from AVIF.
- libjpeg-turbo (or standard libjpeg): Required to convert JPEG files to and from AVIF.
- zlib: Needed by libpng to compress PNG output.