Hi all. I was following a tutorial for adding a Golang app with snapcraft:
The app builds okay with multipass but when trying to execute, I get this error:
error while loading shared libraries: libasound.so.2: cannot open shared object file: No such file or directory
I’m confused because I’ve added this library under the build packages (I’ve tried libasound2-dev as well as just libasound2).
Any advice is appreciated thanks.
---
name: myapp
license: GPL-3.0+
version: git
summary: mysummary
icon: snap/gui/logo.png
description: my description
confinement: devmode
base: core18
parts:
myapp:
plugin: go
go-importpath: github.com/myname/myapp
source: .
source-type: git
build-packages:
- gcc
- make
- libsdl1.2-dev
- libasound2
- libpng-dev
- libsdl-net1.2-dev
- libc6-dev
- libglu1-mesa-dev
- libgl1-mesa-dev
- libxcursor-dev
- libxi-dev
- libxinerama-dev
- libxrandr-dev
- libxxf86vm-dev
- pkg-config
apps:
myapp:
command: bin/myapp
...
In order to use it at runtime after the snap is built, you should put the package under stage-packages
, not build-packages
. build-packages
is really for libraries/tools/etc that are needed only at build time to build the application, but stage-packages
is for libraries/tools/etc that your application uses at runtime.
Thank you for replying so fast. I’ll give that a shot.
well that error seems to be replaced with a new one:
panic: exec: "gsettings": executable file not found in $PATH
Looks like a Golang library that I am using is maybe missing a dependency but not sure… hmmm
The traceback leads to this:
/root/parts/myapp/go/pkg/mod/github.com/hajimehoshi/ebiten@v1.12.0/internal/uidriver/glfw/ui.go:120 +0x25
Looking at the library’s code: https://github.com/hajimehoshi/ebiten/blob/master/internal/uidriver/glfw/ui.go I have no idea why it’s panicking
ogra
October 2, 2020, 3:56pm
5
$ dpkg -S $(which gsettings)
libglib2.0-bin: /usr/bin/gsettings
$
you want libglib2.0-bin
in your stage-packages
…
ogra:
libglib2.0-bin
Hi ogra. Thanks I’ll give that a shot
okay got a new one:
libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
I figured adding mesa-utils and libgl1-mesa-glx would fix but unfortunately not…
This is what my build and stage packages look like now:
build-packages:
- gcc
- make
- libsdl1.2-dev
- libpng-dev
- libsdl-net1.2-dev
- libc6-dev
- libglu1-mesa-dev
- libgl1-mesa-dev
- libxcursor-dev
- libxi-dev
- libxinerama-dev
- libxrandr-dev
- libxxf86vm-dev
- pkg-config
stage-packages:
- libasound2-dev
- libgl1
- libglvnd0
- libglx0
- libx11-6
- libxau6
- libxcb1
- libxdmcp6
- libglib2.0-bin
- mesa-utils
- libgl1-mesa-glx
ugh no luck still… added the desktop-glib-only sections etc. It’s at leas reaching my application logs now
2020/10/02 13:02:57 VersionUnavailable: GLX: Failed to create context: GLXBadFBConfig
but still getting this error when running the installed Snap:
libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
ogra
October 2, 2020, 5:34pm
11
you want to use either an extension (like gnome-3-34-1804) or a desktop-helper part here so the LibGL paths as well as the LD_LIBRARY_PATH have all the right bits set for OpenGL operation (and can manage the various graphics drivers a host could use) …
name: desktop-helpers
version: 1
summary: Various technology desktop helpers for snapcraft
description: |
Note: We are currently in the process of moving most of the functionality of the
desktop helpers to Snapcraft Extensions. The extensions are much easier to use
and contain many improvements. Please read the documentation on snapping
desktop applications to see what the best way is to create a snap for
your application: https://forum.snapcraft.io/t/desktop-applications/13034
.
Helpers for gtk2, gtk3, qt4 and qt5 or gnome-platform and glib minimal launchers.
It brings the necessary code and exports for binding and using those
desktop technologies in a relocatable fashion, enabling binding with
global desktop theme, icon theme, image caching, fonts, mimetype handlers
application global menu and gsettings integration.
It also brings basic ubuntu dependency packages.
.
Usage:
1. copy the part of the toolkit you need to your snapcraft.yaml file:
- gtk2, gtk3, qt4 and qt5 corresponds to their respective toolkit
This file has been truncated. show original
Well I was going to give up and then saw that post about extensions. It’s close to working now but not 100%.
The app now opens briefly and crashes (I’m guessing because of audio).
After looking at the mentioned extensions link, my yaml now looks like this:
---
name: myapp
license: GPL-3.0+
version: git
summary: my summary
icon: snap/gui/logo.png
description: some description
confinement: devmode
base: core18
parts:
myapp:
plugin: go
go-importpath: github.com/myname/myapp
source: .
source-type: git
build-packages:
- gcc
- make
- libsdl1.2-dev
- libpng-dev
- libsdl-net1.2-dev
- libc6-dev
- libgl1-mesa-dev
- libxcursor-dev
- libxi-dev
- libxinerama-dev
- libxrandr-dev
- libxxf86vm-dev
- pkg-config
stage-packages:
- libasound2-dev
- libgl1
- libglvnd0
- libglx0
- libx11-6
- libxau6
- libxcb1
- libxdmcp6
- libglib2.0-bin
- mesa-utils
- libgl1-mesa-glx
- libgl1-mesa-dri
- libglu1-mesa
- libgles2-mesa
- libflac8
- libxcursor1
- libxi6
- libxinerama1
- libxrandr2
- libxrender1
- libasound2
- libasyncns0
- libogg0
- libpulse0
- libsndfile1
- libtheora0
- libvorbis0a
- libvorbisenc2
- libvorbisfile3
- libwebp6
apps:
myapp:
extensions: [gnome-3-28]
command: bin/myapp
plugs:
- audio-playback
- desktop
- desktop-legacy
- home
- x11
- unity7
- browser-support
- network
- gsettings
- pulseaudio
- alsa
- opengl
...
I now get this when the app crashes:
ALSA lib conf.c:3916:(snd_config_update_r) Cannot access file /usr/share/alsa/alsa.conf
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM default
And inside of my logs:
2020/10/02 17:31:22 oto: ALSA error: No such file or directory
I found this link Cannot access file /usr/share/alsa/alsa.conf if not using --devmode flag but I’m not sure if it is applicable. I’m running with --devmode and I “think” that I have the appropriate extensions.
golgo13
October 2, 2020, 11:24pm
13
Okay finally got it working with @lucyllewy 's example here: Reusable alsa-lib part - #24 by lucyllewy
The layout and alsa parts fixed it.
1 Like