Snap with gtk/gtkmm/pango/cairo and error on run

Hi all,

I am trying to build mysnap with extensions: [gnome-3-34] and everything is fine - I have mysnap for x64 arch. But when I run it, I got the error with the next log:

snap run mysnap
Warning: Schema “org.gnome.system.locale” has path “/system/locale/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy” has path “/system/proxy/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.http” has path “/system/proxy/http/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.https” has path “/system/proxy/https/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.ftp” has path “/system/proxy/ftp/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
Warning: Schema “org.gnome.system.proxy.socks” has path “/system/proxy/socks/”. Paths starting with “/apps/”, “/desktop/” or “/system/” are deprecated.
/snap/mysnap/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0: symbol lookup error: /snap/mysnap/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: pango_font_description_set_variations
ERROR: /snap/mysnap/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0 exited abnormally with status 127
/snap/mysnap/x1/usr/bin/mysnap: symbol lookup error: /snap/mysnap/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: pango_font_description_set_variations

I use gtk/gtkmm/pango/cairo in mysnap app, how can I fix it? Thanks!

Can you post your snapcraft.yaml file? This might help finding the issue.

Yes, sure:

name: mysnap
title: mysnap app
version: "1.0"
type: app
description: |
    some description

#confinement: classic
confinement: devmode
base: core18
icon: mysnap/icons/48x48/mysnap.png
license: Proprietary
#grade: stable
grade: devel

architectures:
  - build-on: x64_64
    run-on: x64_64

parts:
  nativelib:
    plugin: make
    source: ./nativelib
    build-environment:
    - NATIVELIB_ROOT: "$SNAPCRAFT_PART_BUILD"
    override-build: |
      ./src/snap.sh
    build-packages:
      - g++
      - gcc
      - make
      - pkg-config
      - libglib2.0-dev
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libgstreamer-plugins-good1.0-dev
      - libgstreamer-plugins-bad1.0-dev
      - gstreamer1.0-vaapi
      - libssl1.0-dev
      - libxml2-dev
      - libpcre3-dev
      - zlib1g-dev
    stage-packages:
      - libglib2.0-dev
      - gstreamer1.0-x
      - libgstreamer1.0-0
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-vaapi
      - libgpm2
      - libslang2
      - openssl
      - libxml2
      - libpcre3
      - zlib1g
  mysnap:
    after:
    - nativelib
    plugin: make
    source-type: local
    source: ./mysnap
    build-environment:
    - MYSNAP_ROOT: "$SNAPCRAFT_PART_BUILD"
    - OPENSSL_ROOT_CONFIG: "$SNAPCRAFT_PART_INSTALL/usr/include/x86_64-linux-gnu"
    - INSTALL_DIR: "$SNAPCRAFT_PRIME"
    override-build: |
      ./gtkmm/snap.sh
    build-packages:
      - g++
      - gcc
      - make
      - pkg-config
      - libglib2.0-dev
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libgstreamer-plugins-good1.0-dev
      - libgstreamer-plugins-bad1.0-dev
      - gstreamer1.0-vaapi
      - libsigc++-2.0-dev
      - libssl1.0-dev
      - libxml2-dev
      - libgl1
      - libglvnd0
      - libglx0
      - libgpm2
      - libslang2
      - libpcre3-dev
      - zlib1g-dev
      - file
    stage-packages:
      - libglib2.0-dev
      - gstreamer1.0-x
      - libgstreamer1.0-0
      - gstreamer1.0-plugins-base
      - gstreamer1.0-plugins-good
      - gstreamer1.0-plugins-bad
      - gstreamer1.0-vaapi
      - libsigc++-2.0-0v5
      - openssl
      - libxml2
      - libgpm2
      - libslang2
      - libpcre3
      - freeglut3
      - libglu1
      - zlib1g

apps:
  mysnap:
    command: usr/bin/snaprun.sh
    extensions: [gnome-3-34]

Can you edit your comment to put the code in a code block like this? That makes it a lot easier to parse your file.

```yaml
name: mysnap
title: mysnap app
version: “1.0”
type: app
description: |
some description
...
```

Thanks!

This error makes me think that there is a mismatch between the version of GTK 3 your application was built for and the version of GTK 3 that is used in the snap. Could you maybe try the gnome-3-34 extension instead? That extension does a bit more setup of the build environment to make sure the correct version of GTK 3 is used.

It might also be best to remove libglib2.0-dev from build and stage packages since that is provided by the extension and the versions might conflict.

Yes, I already removed this dep from snapcraft :slight_smile:

This error makes me think that there is a mismatch between the version of GTK 3 your application was built for and the version of GTK 3 that is used in the snap. Could you maybe try the gnome-3-34 extension instead? That extension does a bit more setup of the build environment to make sure the correct version of GTK 3 is used.

Hmmm, I use gnome-3-34 extension…

Maybe I should manually add glib/gtk/pango and other libs to stage/build packages instead of use gnome-3-34 extension?

That will probably give you a lot more issues than it will fix. The extension does a lot for you.

As a sanity check, have you tried a clean build and a clean install? It might be that the build environment is tainted if you experimented a lot while building your snap. Have you tried running snapcraft clean and re-run snapcraft? And run snap remove mysnap --purge before installing the resulting snap.

Maybe @hellsworth has any idea what might be going on here?

Yes, of course I tried this.
BTW I tried to search symbol pango_font_description_set_variations inside all built snap files, but it could not be found.

Yes, it seems to be gtk-query-immodules-3.0 of the gnome-3-34-1804 platform snap which tries to lookup the symbol.

  • One thing you could try is use the cleanup part to make all duplicated (and thus possibly incompatible) libraries are removed from your snap.
  • Another thing you could try is using the gnome-3-28 extension instead. The GTK version in that extension is much closer to the one of Ubuntu 18.04, so you have less chance of getting incompatibilities.
  • Lastly, it might help us if you could provide us with the snap. I see the application itself is proprietary; is the snap publicly available?

If you want a more clear picture of what is going wrong, it might be interesting to open a shell in the environment of the snap snap run --shell mysnap and look at what libraries /snap/mysnap/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3-0/gtk-query-immodules-3.0 and /snap/mysnap/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0 are linking to using ldd: ldd /snap/mysnap/x1/gnome-platform/usr/lib/x86_64-linux-gnu/libgtk-3.so.0.

All the libraries it links to should come from /snap/mysnap/x1/gnome-platform (this is where gnome-3-34-1804 is mounted in your snap). If that’s not the case, that might be the issue.

Thank you very much for your time and help. gnome-3-28 extension with gtkmm libs helped me. Now the snap with app works. I really appreciate your help to me :slight_smile:

1 Like

Hmm I’m glad that using the gnome-3-28 extension solved the issue for you, but it would be good to know what’s going on here with the gnome-3-34 extension though. @RomanS would it be possible to share the snap with me so I could debug it?

1 Like

This is proprietary snap, I cannot to share it. I think the problem inside the next code:

		netstr_snprintf(fontstr, sizeof(fontstr), "Helvetica Normal Bold %d", calch);

		desc = Pango::FontDescription(string(fontstr));
		desc.set_weight(Pango::Weight::WEIGHT_BOLD);
		desc.set_style(Pango::Style::STYLE_NORMAL);
		desc.set_variant(Pango::VARIANT_NORMAL);
		desc.set_stretch(Pango::STRETCH_NORMAL);

		layout = Pango::Layout::create(cr);
		layout->set_text(initials);
		layout->set_alignment(Pango::ALIGN_LEFT);
		layout->set_width(-1);
		layout->set_font_description(desc);
		layout->set_auto_dir(true);
		layout->get_pixel_size(layoutw, layouth);

As I already mentioned, I use gtkmm, my pkg-config:

CFLAGS=$(shell pkg-config --cflags pangocairo pango cairo gtk+-3.0 gtkmm-3.0 gdk-3.0 webkit2gtk-4.0 gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 gstreamer-gl-1.0 libnotify libxml-2.0 x11)
LFLAGS=$(shell pkg-config --libs pangocairo pango cairo gtk+-3.0 gtkmm-3.0 gdk-3.0 webkit2gtk-4.0 gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0 gstreamer-gl-1.0 libnotify libxml-2.0 x11)

You can write simple c++ app and repeat the problem. And you already have my snapcraft.yaml :slight_smile: