Shared Libraries

This seems to be a recurring theme in my experience in building snaps.

I have a snap for tuning software that was working until about a week ago. I’ve been trouble shooting the issue since. As the issues have been different with each revision (bear in mind that I had 3 successful/working builds), this is the most recent and lingering:

megatunix: error while loading shared libraries: libgtkgl-2.0.so.1: cannot open shared object file: No such file or directory

I’ve done some investigation and made some attempts to TELL the snap where the libs are located but to no avail.

Here’s a copy of my current .yaml

 name: megatunix # you probably want to 'snapcraft register <name>'
version: '0.9.9+git' # just for humans, typically '1.2+git' or '1.3.2'
summary: MegaTunix Tuning software for MegaSquirt EFI Controllers # 79 char long summary
description: |
  MegaTunix is a tuning application for Linux, Mac OS-X, other Unix variants and Windows XP/Vista/7 32 bit variants. It supports some of the available DIY EFI Fuel injection solutions including many MegaSquirt products and LibreEMS. It's written in C using the GTK windowing toolkit and is licensed under GPL V2.

grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots

apps:
  megatunix:
    command: desktop-launch $SNAP/bin/megatunix
    desktop: share/applications/megatunix.desktop
    environment:
      LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/usr/lib/
    plugs:
      - home
      - unity7
      - x11
      - removable-media
      - raw-usb
    

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: autotools
    source: https://github.com/djandruczyk/MegaTunix
    source-type: git

 

build-packages:
  - libgtkglext1
  - libglade2-dev
  - libtool-bin
  - intltool
  - flex
  - bison
  - libgtkgl2.0-dev


stage-packages:
  - libgtkglext1
  - libglade2-dev
  - libtool-bin
  - intltool
  - flex
  - bison
  - libgtkgl2.0-dev

install: | 
  cd bin     
  sudo make install
  sudo ldconfig

Again, the snap builds successfully. It RAN for 3 separate revisions (the revisions were to add desktop support, etc). Now, it fails with the aforementioned error.

TIA.

is your yaml really like that (with build-packages, stage-packages and install on the top level ) ?

if so i doubt the packages will even be considered for installation, though i would expect snapcraft to spill an error when you try to build this, the yaml validation should really block on it.

note that the envionment setting is redundant, these are defaults wrapped around every snap application …

what does:

find /snap/megatunix -name libgtkgl-2.0.so.1

return … (does it find the file in the installed snap ?)

Not only does it build (locally), it WAS running. This latest .yaml is an attempt to just get it to work again. The first revisions (the ones that worked) did not have the stage-packages at all, but quit working. I “think” there was an update to snapd, but that doesn’t matter either since the snap still doesn’t work anymore.

That said, here’s the output of find /snap/megatunix -name libgtkgl-2.0.so.1

/snap/megatunix/8/usr/lib/libgtkgl-2.0.so.1

I’ve attempted so many different .yaml configurations, I’ve lost count and quit trying to track each revision. I am totally at a loss.

And BTW, thanks for your assistance!

I just tried your yaml as it is written in the box in your first message to test in case you’re mistaken. The yaml does not work as-is. If you are able to build then you are not building with the yaml you posted above. Do you have multiple snapcraft.yaml files? Are you sure you’re building against the yaml you think you are? It would be helpful if you could checkin everything you have to a git repository so that we can be sure we’re all singing from the same hymn-sheet.

Looking through your yaml, I see you are including -dev packages in the final snap. This is discouraged as it will include a lot of irrelevant stuff for runtime use. You should replace the -dev references in stage-packages with the equivalent non -dev; try apt show some-package-dev to find the actual library package name e.g. for libgtkgl2.0-dev you want libgtkgl2.0-1.

You also likely do not need flex, bison, and libtool-bin in the final snap as those are used to build programs rather than run them.

The install steps are handled by snapcraft without being manually specified, except the ldconfig call which shouldn’t be necessary anyway. Do you know what that call is trying to fix because it is not normal to do that when installing compiled libraries?

you’re also missing an appropriate desktop-launcher configuration, such as after: [desktop-gtk2]

Yes I am, in fact, you can download the latest build (albeit malfunctioning):

sudo snap install --edge megatunix

I am in no way trying to be combative, just attempting to paint this confusing picture.

Again, I really appreciate your help in the matter.

As I attempted to build the latest versions of the snap, I was getting an error about shared libraries and the desktop-gtk2 wanting to share the same folder.

Does that make any sense to you? It confused me as the original builds never complained about that.

Several attempts to change that up rendered failed attempts to build.

The current yaml is seriously a flailing attempt to get it to work again…it’s bad practice, I know but that’s why I’ve reached out to you guys, I am totally lost.

Here’s a video of it actually working (so you don’t think I’m crazy).

https://www.youtube.com/watch?v=aQHyWLs0wDA

That was a clean build, no issues at all.

Now, that very same version will not work…

how exactly are you building ?

  • what is the snapcraft command you use (exact copy /paste fom the terminal (note you should use “snapcraft cleanbuild”))
  • on what system/release are you building it
  • are you using the snapcraft classic snap or the deb

using your snapcraft.yaml fom above i get (as expected):

ogra@anubis:~$ snapcraft cleanbuild
Issues while validating snapcraft.yaml: Additional properties are not allowed ('install', 'stage-packages' were unexpected)
ogra@anubis:~$

changing your snapcraft.yaml to have corect indendation like http://paste.ubuntu.com/25731436/

makes it fail with:

/root/build_megatunix/parts/my-part/install/usr/bin/ld: cannot find -lGLU
collect2: error: ld returned 1 exit status

(so some build-packages dependency on libGLU* is missing here as well …)

I am using the snapcraft deb.
Yes, snapcraft cleanbuild

You can download a completed snap via: sudo snap install --edge megatunix

I’m on Ubuntu 16.04.3

I don’t know why it’d build on my system and not yours. I can’t answer that.

It WAS also building on build.snapcraft.io but now doesn’t. I’d cite the issues you guys are referencing above.

What I am really trying to do, is just figure out the shared libs issue.

If anything, I can just rewrite the yaml (again) and see if that takes. BUT, after multiple attempts, multiple revisions, the same issue keeps cropping up: megatunix: error while loading shared libraries: libgtkgl-2.0.so.1: cannot open shared object file: No such file or director

That’s been the consistent error (regardless of how it’s getting built). Bear in mind, this was not showing up before revision four and a snapd update.

well, the point is, as @lucyllewy already mentioned that your snapcraft.yaml is tecnically not valid yaml, please check if you have any other snapcraft.yaml hidden anywhere in your tree, the call to snapcraft should spin up the yaml validator (like it does for all of us) and tell you that the yaml is broken …

we will not be able to help if we are not all on the same base here with the same working snapcraft.yaml as a starting point …

No other .yaml

I don’t know what to do. I am about ready to give up as I am not a dev (bet you can tell), just trying to learn how to package snaps; for learning’s sake.

Do what they’re asking. Push your code somewhere so that they can look at it.

Here’s a link to my .yaml on github: https://github.com/kz6fittycent/megatunix/blob/master/snapcraft.yaml

Here’s the developer’s github: https://github.com/djandruczyk/MegaTunix

This project may not even be viable any longer as a lot of development has shifted to mobile. Some of the tuners are just using their tablets or phones (which is odd to me). So, I wanted to build this snap to revive the project and make it a viable option for all the Linux users who are also into performance automotive.

UPDATE:

I decided to completely start over again. Here are the steps I followed (video to be posted shortly).

Removed ALL files in ~/megatunix

Removed all entries in snapcraft.yaml and started from a basic config (just git repo and autotools) and awaited errors.

Added after: [desktop-gtk2] and awaited other errors.

Added build-packages

No errors.

Snap builds.

Runs.

I will post a video of my steps so you can see. I will also update my .yaml in github to match this “new” one.

Here’s the new .yaml:

name: megatunix # you probably want to 'snapcraft register <name>'
version: '0.9.9+git' # just for humans, typically '1.2+git' or '1.3.2'
summary: MegaTunix Tuning software for MegaSquirt EFI Controllers # 79 char long summary
description: |
  MegaTunix is a tuning application for Linux, Mac OS-X, other Unix variants and Windows XP/Vista/7 32 bit variants. It supports some of the available DIY EFI Fuel injection solutions including many MegaSquirt products and LibreEMS. It's written in C using the GTK windowing toolkit and is licensed under GPL V2.
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  megatunix:
    command: desktop-launch $SNAP/bin/megatunix
    desktop: share/applications/megatunix.desktop

parts:
  my-part:
    # See 'snapcraft plugins'
    plugin: autotools
    source: https://github.com/djandruczyk/MegaTunix
    source-type: git
    after: [desktop-gtk2]

    build-packages:
      - libgtkglext1
      - libglade2-dev
      - libtool-bin
      - intltool
      - flex
      - bison
      - libgtkgl2.0-dev

Here’s the error it’s throwing on build.snapcraft.io:

/usr/bin/ld: cannot find -lGLU collect2: error: ld returned 1 exit status Makefile:542: recipe for target 'libmtxyamlcpp.la' failed make[2]: *** [libmtxyamlcpp.la] Error 1 make[2]: Leaving directory '/build/740792a70b60d37a6341e1fbeb32cc8f-xenial/parts/my-part/build/yaml-cpp' make[1]: *** [all-recursive] Error 1 Makefile:512: recipe for target 'all-recursive' failed make[1]: Leaving directory '/build/740792a70b60d37a6341e1fbeb32cc8f-xenial/parts/my-part/build' Makefile:432: recipe for target 'all' failed make: *** [all] Error 2

Why would it build locally but not on the build site?

try adding libglu1-mesa-dev to your build-packages now …

also … my assumption is that you either do not run the snap at all, but a local non-snapped copy (by accident) or that you simply have some kind of mix of snap/non-snap bits on your local machine … weird is still that “snapcraft cleanbuild” did not throw the same libGLU error for you that i am seeing and that build.snapcraft.io is also reproducing (the cleanbuild command runs the whole build in a virgin container, instead of natively on your host machine)…

Will do, thanks.

BTW, there is no copy of megatunix available out there. You have to compile it from source (always been that way). So, any version that ran on my system would’ve been from the snap.

I’ve switched gears again and I’ve decided (just to eliminate any other variables) to ONLY build via build.snapcraft.io

If it won’t build there, it’s not getting built. Period.