Subject: bug#49122: gobject-introspection and not finding cairo

From: John Kehayias <[email-masked]>
Date: Sat, 19 Jun 2021 18:29:05 +0000

Hello,

I'm trying to build some new packages, one of which is ghc-gi-cairo (from ghc-haskell-gi: https://github.com/haskell-gi/haskell-gi). These depend on gobject-introspection and finding library information from gir. However, it appears the typelib for cairo does not include the absolute path for cairo (though gobject-introspection right now does not depend on cairo, so that makes sense?) and the library cannot be found from this info.

Perhaps the name exposed in the typelib should be something else? I know there are patches for paths in gobject-introspection, and this issue of library path from gobject-introspection is not just in guix (e.g. https://github.com/Cimbali/pympress/issues/58). In building I do see LIBRARY_PATH includes the correct gobject-introspection (it does find the girepository in configure) and cairo, but as far as I can tell the path to cairo must be found via the typelib when using gobject-introspection?

I've tried building gobject-introspection with cairo enabled in meson, which didn't help. I also tried patching the cairo.gir file (as in https://github.com/Cimbali/pympress/issues/58#issuecomment-503174954), but haven't figured out what needs to go in there to make it work. Probably gobject-introspection needs to be build with cairo as an input and correctly get the full path to the library in generating the typelib? But what goes in the gir/cairo-1.0.gir.in file exactly?

>From the gobject-introspection package running:

strings /gnu/store/irmw6agiw3adqphw8c3m19g31fw1yf34-gobject-introspection-1.62.0/lib/girepository-1.0/cairo-1.0.typelib | grep lib

has output:

libcairo-gobject.so.2
xlib

End of building ghc-gi-cairo has the following message:

starting phase `configure'
running "runhaskell Setup.hs" with command "configure" and parameters ("--prefix=/gnu/store/w95yciqs7i7aqm6v7qa6fiy6m6f25czb-ghc-gi-cairo-1.0.25" "--libdir=/gnu/store/w95yciqs7i7aqm6v7qa6fiy6m6f25czb-ghc-gi-cairo-1.0.25/lib" "--docdir=/gnu/store/w95yciqs7i7aqm6v7qa6fiy6m6f25czb-ghc-gi-cairo-1.0.25/share/doc/ghc-gi-cairo-1.0.25" "--libsubdir=$compiler/$pkg-$version" "--package-db=/tmp/guix-build-ghc-gi-cairo-1.0.25.drv-0/package.conf.d" "--global" "--enable-tests" "--enable-shared" "--enable-executable-dynamic" "--ghc-option=-fPIC" "--ghc-option=-optl=-Wl,-rpath=/gnu/store/w95yciqs7i7aqm6v7qa6fiy6m6f25czb-ghc-gi-cairo-1.0.25/lib/$compiler/$pkg-$version")

** (process:19): WARNING **: 17:28:36.142: Failed to load shared library 'libcairo-gobject.so.2' referenced by the typelib: libcairo-gobject.so.2: cannot open shared object file: No such file or directory
Could not resolve symbol "cairo_gobject_context_get_type" in namespace "cairo-1.0"

Appreciate any tips, help, or things to try!

John