Dllmap target

I’m making a snap of an mono/xamarin gtk app.

It uses mono-complete which installs a lot of .libraries and .dll

In these libs there are some .dll.config files.

These .dll.config files contains lines like

<dllmap dll="gtksharpglue-2" target="/usr/lib/cli/gtk-sharp-2.0/libgtksharpglue-2.so"/>
<dllmap dll="glibsharpglue-2" target="/usr/lib/cli/glib-sharp-2.0/libglibsharpglue-2.so"/>

That means that the mono + app searches for the corresponding .so starting from / where it can’t be found. They are in $SNAP/ and I get a lot of errors like

[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for ‘Gtk.Container’ threw an exception. —> System.DllNotFoundException: ~/usr/lib/cli/gtk-sharp-2.0/libgtksharpglue-2.so assembly: type: member:(null)

Question How do I specify that the .so files must be searched from $SNAP/

In snapcraft.yaml ?

MONO_PATH

is set to

MONO_PATH: $SNAP/etc/mono:$SNAP/usr/bin:$SNAP/usr/lib:$SNAP/usr/lib/mono:$SNAP/usr/share/mono:$SNAP/usr/lib/cli:$SNAP/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0:$SNAP/usr/lib/x86_64-linux-gnu:$SNAP/usr/lib/cli/gtk-sharp-2.0:$SNAP/usr/lib/cli/glib-sharp-2.0:$SNAP/usr/lib/cli/atk-sharp-2.0:$SNAP/usr/lib/cli/gdk-sharp-2.0

1 Like

You have alternatives.

  1. When building the snaps you can sed --in-place "s!/usr/lib/cli/glib-sharp-2.0!\$SNAP/usr/lib/cli/glib-sharp-2.0!g" $SNAPCRAFT_PART_BUILD/...
  2. You can use a layout:
layout:
  /usr/lib/cli/gtk-sharp-2.0:
    bind: $SNAP/usr/lib/cli/gtk-sharp-2.0
  1. You can use a preload shim that intercepts open() and rewrites the path to include $SNAP.

There are pros and cons to each approach.

I would recommend using the layout method. This is the most robust and least likely to have unintended consequences.

1 Like