Detailed compilation instructions

A full build of librsvg requires the meson build system. A full build will produce these artifacts (see Librsvg as a product for details):

  • rsvg-convert binary and its man page.

  • librsvg shared library with the GObject-based API.

  • GDK-Pixbuf loader for SVG files.

  • HTML documentation for the GObject-based API, with gi-docgen.

  • GObject-introspection information for language bindings.

  • Vala language bindings.

Some of the artifacts above are optional; please see the section Compile-time options below for details.

It is perfectly fine to ask the maintainer if you have questions about the meson setup; it’s a tricky bit of machinery, and we are glad to help.

The rest of this document explains librsvg’s peculiarities apart from the usual way of compiling meson projects.

Build-time dependencies

To compile librsvg, you need the following packages installed. The minimum version is listed here; you may use a newer version instead.

Compilers and build tools:

Mandatory dependencies:

Optional dependencies:

See Setting up your development environment for details on how to install these dependencies.

Basic compilation instructions

If you are compiling a tarball:

mkdir -p _build
meson setup _build -Ddocs=enabled -Dintrospection=enabled -Dvala=enabled
meson compile -C_ build
meson install -C _build

The options that start with -D are listed in the meson_options.txt file and are described in the next section.

Compile-time options

These are invoked during meson setup as -Doption_name=value. See meson’s documentation on using build-time options for details.

These are librsvg’s options:

  • introspection - Specifies whether the build will generate GObject Introspection information for language bindings. Values are enabled/disabled/auto.

  • pixbuf - Specifies whether to build with support for gdk-pixbuf in the library APIs. Values are enabled/disabled/auto.

  • pixbuf-loader - Specifies whether to build a gdk-pixbuf module to let applications which use gdk-pixbuf load and render SVG files as if they were raster images. Values are enabled/disabled/auto.

  • docs - Specifies whether the C API reference and the rsvg-convert manual page should be built. These require gi-docgen <https://gnome.pages.gitlab.gnome.org/gi-docgen/>`_ and ``rst2man from Python’s docutils, respectively. Values are enabled/disabled/auto.

  • vala - Specifies whether a Vala language binding should be built. Requires the Vala compiler to be installed. Values are enabled/disabled/auto.

  • tests - Specifies whether the test suite should be built. Value is a boolean that defaults to true.

  • triplet - Specifies the Rust target triplet; only needed for cross-compilation. Value is a string.

  • avif - Specifies whether the image-rs crate, which librsvg uses to load raster images, should be built with support for the AVIF format. Requires the dav1d library. Values are enabled/disabled/auto.

  • rustc-version - Specifies the rustc version to use; only supported on Windows. Value is a string.

Building with no network access

Automated build systems generally avoid network access so that they can compile from known-good sources, instead of pulling random updates from the net every time. However, normally Cargo likes to download dependencies when it first compiles a Rust project.

You can use cargo vendor to download librsvg’s Rust dependencies ahead of time, so that subsequent compilation don’t require network access.

Build systems can use Cargo’s source replacement mechanism to override the location of the source code for the Rust dependencies, for example, in order to patch one of the Rust crates that librsvg uses internally.