Cairo-rs surface features need to be conditinally built
Note: issue completely edited because the rabbit hole is much deeper than it seemed.
Building librsvg with cairo built with --disable-svg (for bootstrapping purposes) fails.
I assumed that it was rsvg-convert conversion to rust that caused the issue because build failed when linking rsvg-convert.
However hacking Makefile.am to disable rsvg-convert showed that the problem is more severe.
Yet another chicken-egg problem ...
ld: ./.libs/librsvg-2.so: undefined reference to `cairo_svg_version_to_string'
ld: ./.libs/librsvg-2.so: undefined reference to `cairo_svg_surface_restrict_to_version'
ld: ./.libs/librsvg-2.so: undefined reference to `cairo_svg_surface_set_document_unit'
ld: ./.libs/librsvg-2.so: undefined reference to `cairo_svg_surface_get_document_unit'
ld: ./.libs/librsvg-2.so: undefined reference to `cairo_svg_get_versions'
The problem is here: https://gitlab.gnome.org/GNOME/librsvg/-/blob/master/Cargo.toml#L16
This patch solves the problem of building the library itself.
diff --git a/Cargo.toml b/Cargo.toml
index 84152e52..d263bdb0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ crate-type = [ "staticlib", "rlib" ]
bitflags = "1.0"
# Keep these in sync with respect to the cairo-rs version:
# src/lib.rs - toplevel example in the docs
-cairo-rs = { version="0.8.0", features=["v1_16", "png", "pdf", "ps", "svg"] }
+cairo-rs = { version="0.8.0", features=["v1_16", "png", "pdf", "ps"] }
cairo-sys-rs = "0.9.0"
cast = "0.2.3"
chrono = "0.4.0" # rsvg-convert
But a new wild error appears.
error[E0433]: failed to resolve: could not find `SvgSurface` in `cairo`
--> src/bin/rsvg-convert.rs:208:30
|
208 | let surface = cairo::SvgSurface::for_stream(size.w, size.h, stream.into_write())?;
| ^^^^^^^^^^ could not find `SvgSurface` in `cairo`
error[E0412]: cannot find type `SvgSurface` in crate `cairo`
--> src/bin/rsvg-convert.rs:159:16
|
159 | Svg(cairo::SvgSurface, Size),
| ^^^^^^^^^^ help: a struct with a similar name exists: `PdfSurface`
|
::: /home/asavah/kross/.cargo/registry/src/github.com-1ecc6299db9ec823/cairo-rs-0.8.1/src/pdf.rs:33:1
|
33 | declare_surface!(PdfSurface, SurfaceType::Pdf);
| ----------------------------------------------- similarly named struct `PdfSurface` defined here
Please don't assume that cairo present on the system is linked with librsvg when building librsvg. This is a mess now.
Edited by Federico Mena Quintero