Snap from binaries - Map library folders

I have some binaries that are cross-compiled on another machine. The binarie are meant to be run on embedded Linux boards and, for demo purposes, we usually run them on a qemu machine on a PC. What I’d like to do is to wrap them in snap and try to run them like we do with qemu. That’s an experiment from our side, not sure if it’s possible and it’ll work.

Anyway, the binaries expect the needed libraries to be located in /lib and /usr/lib folders and they shall be the correct ones to run. So, I copied those libraries in two local folders named sysroot/lib and sysroot/usr/lib and pack them together with the binaries in an archive, which is installed by snapcraft using the dump plugin.
Now, I’d like to tell snap to “map” those folders to /lib and /usr/lib respectively, so that the applications can successfully run. Is it possible?
I took a look to snap layouts but it seems to me it’s not what I need.

Thanks

layout is surely the right thing if you hardcode the path in your app. but you will need to map them one by one … it would be better if you can convince your app to i.e. look in some subfolder of /lib so you could just map the directory via the layout …

alternatively you could not hardcode any path but have your app properly use the linker and simply append $SNAP/sysroot/lib to LD_LIBRARY_PATH in the environment block of the snapcraft.yaml app section …