Snaps no longer running since 18.04

Hello everyone,

First of all forgive my ignorance as I am not very familiar with Ubuntu/Linux.

The problem: Since we upgraded to Ubuntu 18.04 we have switched to GCC/G++ 7 (7.3 to be exact). This is version you can easily install by running "sudo apt install gcc-7-bla-bla, so not a custom version build by source or anything special. Since then, we get the following error for all our applications:

kiosceditor: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.11’ not found (required by kiosceditor)

kiosceditor: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22’ not found (required by kiosceditor)

and here is the versions of GCC/G++

gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright © 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright © 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

I don’t see why it would not work or even require gcc and g++ installed.

Thank you very much in advance for you help.

I don’t know the details of your snap, but I suspect your snap is strictly confined, and that you’re building it directly on 18.04. This won’t work: the environment in which a snap runs is dictated by its base, which defaults to core, which is 16.04. By building on 18.04 you’re linking it against a newer libc than is available to it when it runs.

Have you tried using snapcraft cleanbuild?

Hello John,

Thank you for the quick response. But then why wouldn’t it run for 18.04? and does this mean I need to build with 16.04?

Greetings,
Michael

The environment in which a strictly-confined snap runs is dictated by its base. The libc of the system you run it in does not enter the picture, it has no access to it.

Yes, you need to build for the base you will run it on. That’s what cleanbuild does.

If you need to build on 18.04 for whatever reason, then specify base: core18. But note this has other consequences, which somebody more savvy in snapcraft itself can probably explain better than I.

Hello John,

Thank you very much for your reply, I will try “cleanbuild” right away and see if that solves my issue.

In my case I want to be able to build on 18.04 but I want it to run on both 16.04 and 18.04 regardeless.

Greetings,
Michael.

If by “build” you mean “use [features from] libraries that are in 18.04 and not in 16.04”, then you’ll need base: core18; otherwise, if you just mean “develop on 18.04 because that’s what my dev box is on”, cleanbuild will do what you need.

1 Like

Hello John,

Yes, when I say build I mean where I develop, the system I use to compile and at the end create the snap package.

I did use “cleanbuild” which requires “LXD” which I also installed. Sorry to further ask you annoying questions, but do I need to install all my dependencies(boost or cmake) in the LXD Container?

Greeting,
Michael.

If using snapcraft, through snapcraft.yaml the way to do it is through build-packages defined here https://docs.snapcraft.io/snapcraft-parts-metadata/8336

Hello Sergio,

Thank you for your reply. I do use snapcraft, and I have followed the link before, but it is not providing enough information unfortunately. Now that I am building with “cleanbuild” my make command fails. What I do is: I run my cmake command to generate my makefile and inside my snapcraft.yalm I rum my make command.

parts:
myapp:
plugin: make
source: .
build: |
make MyAppRelease -j4

It results in:
Makefile:8764: recipe for target ‘cmake_check_build_system’ failed
make: *** [cmake_check_build_system] Error 1

This requires cmake (or related packages) in build-packages though.

As a side question, are you doing ROS development by any chance? I only ask because ROS related results were the top target when searching the web for that build target.

Hello John,

No I am not doing ROS developement its a simple C++ application.
I also did what you suggested, but now it cannot find the directory I am building from:

Building myapp
CMake Error: The source directory “/home/michael/Documents/repo/myapp/script/build_dir/myapp” does not exist.
Specify --help for usage, or press the help button on the CMake GUI.
Makefile:8764: recipe for target ‘cmake_check_build_system’ failed
make: *** [cmake_check_build_system] Error 1

To go further into this. Just doing “snapcraft cleanbuild” is not a solution. I have managed to get cmake to work, and also g++, but the only g++ available is version 5, which is a 3 year old compiler and outdated. Nevertheless for this project I can manage with partial c++ 14, but now my cmake does not seam to work because it cannot find my source code anymore, which I believe is because is executed in /root/my_myapp/build/myapp and my source is not there.

Do I also need to check out/copy all my source code in the build step of the snapcraft script?

Greetings,

If you’ve got a cmake project, Snapcraft can configure it for you with its cmake plugin. Something like:

parts:
  myapp:
    plugin: cmake
    source: .
    configflags:
     - -Dfoo=whatever
     - -Dbar=something

This will invoke cmake with the given configuration flags (so you don’t need to maintain these settings outside of the snapcraft project), followed by make and make install. This plugin will ensure that cmake is installed in the cleanbuild container. If you’ve got any other deps, then you’ll need to define them with build-packages as @sergiusens suggested.

As for requiring a newer C++, the using the core18 base snap is probably the right option: this will allow you to use the newer libstdc++ even when deploying your app to older Ubuntu releases.

Hello Jamesh,

Thank you for your responce, and forgive my frustration, I wish I had enough time to allocate just for becoming familiar with the snapcraft yalm but i dont. I have created a new build system with 16.04 and was forced to build there, which fortunately works but is disappointing that I had to go back to that.

As for requiring a newer C++, the using the core18 base snap is probably the right option: this will allow you to use the newer libstdc++ even when deploying your app to older Ubuntu releases.

A couple questions to that:

  • Am I not using core18 automatically when building/developing on 18.04?
  • If I do switch to core18 will the apps still be able to run on 16.04?

When a strict confined snap application is run, it doesn’t see the root file system of the host system it is running on. Instead, it is run in a separate mount namespace with that uses the chosen base snap as the root file system.

In the past there was only a single choice of base: the core snap, which is essentially a minimal Ubuntu 16.04 install. You can see what this root file system looks like by inspecting the contents of /snap/core/current/.

The suggestion earlier in the thread is to add base: core18 to your snapcraft.yaml, which will instead run your application in a minimal Ubuntu 18.04 install. It is necessary to manually request this: it isn’t implied simply by running the build on an 18.04 machine. Part of the reason for this is that Snapcraft is being reworked to perform all builds in containers or VMs that match the base snap (where currently this is only done for cleanbuild).

As for running your snap, it will use your chosen base snap as root file system no matter what the host system is. This means (a) you can use new C++ features when deploying to old Ubuntu releases, and (b) you don’t have to worry about future Ubuntu releases making changes incompatible with your app.

Hello James,

Thank you for further explaining it to me, this is very helpful. I still have a followup question.

  • In the clean 18.04 installations that I did I found no GCC or G++ installed and so I had to manually install the one of my preference. which ended up 7.3.0. Would that affect a snap that was deployed with base18, when running on 16.04?

Greetings,
Michael.

If you run snap install core18, you can inspect what the 18.04 based root file system looks like by poking around in /snap/core18/current/.

In particular, looking in /snap/core18/current/snap/manifest.yaml, it shows that it was built with libstdc++6=8.2.0-1ubuntu2~18.04, the same version you’d see outside of confinement on an 18.04 host system. This is libstdc++ from 8.2.0, which is compatible with code you compile with g++ 7.3.0.

So if you build your snap with core18 as the base, this is the libstdc++ the app will see no matter what host system it is deployed to. The whole idea of this system is to allow you to test your application on one distro release and be fairly confident that it will run everywhere.

Hello James,

This actually very helpful, I will try that later today. Thank you for your help.

Greetings,
Michael.

1 Like