Libxml2.so.2: cannot open shared object file: No such file or directory

I have a snap which has a dependency on libxml2. I have added

libxml2-dev:arm64 in build-packages and stage packages. But still, at runtime, I get the below error.

dlopen(some_lib.so.1, RLTD_NOW) is failed… libxml2.so.2: cannot open shared object file: No such file or directory.

Some details about the snapcraft.yaml:

base: core22 version: ‘0.1’

grade: stable confinement: devmode

snap version snap 2.58.2 snapd 2.58.2 series 16 kernel 5.15.39

you may need to add a stage dependency

stage-packages:

  • libxml2

I have tried adding the following in the build-packages and stage-packages:

  1. libxml2-dev:arm64 —> “libxml2.so.2: cannot open shared object file: No such file or directory.”
  2. libxml:arm64 —> libxml2.so.2: cannot open shared object file: No such file or directory.
  3. libxml2-dev —> does not compile
  4. libxml2 —> does not compile
  5. libxml2-utils —> libxml2.so.2: cannot open shared object file: No such file or directory.

4 is the correct thing to do… what is the compile error you see ?

Note: With experiments 1,2 and 5. The library libxml2.so is generated. It is present in these paths.

./prime/usr/lib/aarch64-linux-gnu/libxml2.so.2 ./prime/usr/lib/aarch64-linux-gnu/libxml2.so.2.9.13 ./stage/usr/lib/aarch64-linux-gnu/libxml2.so.2 ./stage/usr/lib/aarch64-linux-gnu/libxml2.so.2.9.13

Currently in the snapcraft.yaml apps: environment: LD_LIBRARY_PATH: $SNAP/usr/local/lib/ I think I need to add one more path as, $SNAP/usr/lib/aarch64-linux-gnu

but do we have a provision to add multiple LD_LIBRARY_PATH here?