How to create content interface that shares a C-level library


the documentation for content interfaces lists sharing C-level library as TBD. So, how to create such as interface, is it even possible or still needs implementation on snapd/snapcraft side?


1 Like

I can’t find information on this either.
For example, I wonder where are the header files supposed to be stored? From one side, they are not going to be inside snap - headers useless on target. From other, .h and the .so files should be tied together somehow, since .h corresponds to particular version of the library

I’m still working on this and still need some help in getting it fly.

I have used mir-libs-snap and mir-kiosk as the examples of producer and consumer respectively. Based on them I have following declarations:


    interface: content
    content: tpm2-libs
      - lib
      - usr/lib


    interface: content
    content: tpm2-libs
    target: $SNAP/tpm2-libs
    default-provider: tpm2-libs

Now, as I understand the documentation here are the rules:

  1. content must match between producer and consumer
  2. default-provider is important for auto-connection and should match the producer:slot
  3. target is where the “content” coming from producer will be mounted at the consumer side
  4. read is a path to expose, relative to /snap/$SNAP_NAME/current

However clearly I have something wrong because still whenever I try to use it I get:

/snap/tpm2-tools/x1/sbin/tpm2_listpcrs: error while loading shared
libraries: cannot open shared object file: No such
file or directory

For the reference the tpm2-tools snap that I use here for testing is basically the tmp2 snap without lib directory of tpm2-tss part being primed.

How can I debug this efficiently?

Also for the record, I’m running core v16-2.28.1

Have you adjusted the LD_LIBRARY_PATH environment variable to include your tpm2 library’s path as seen from the view of your consumer snap? e.g. have you included $SNAP/tpm2-libs in the list?