Gcc 9 libstdc++

Hello,
my c++ project is compiled with gcc -9. I have a problem with the libstdc++.so.6.0.28 library. This is a newer version than the standard ubuntu core18 version which is libstdc++.so.6.0.25

Finally I would need the libstdc++.so.6.0.28 library in the /snap/core18/1754/usr/lib//x86_64-linux-gnu/ library but I don’t know how to get it there.

A cp command gives “read only file system…”

Here is my yaml code:
parts:
gcc-9:
plugin: nil
override-pull: |
add-apt-repository -yu ppa:ubuntu-toolchain-r/test
apt install -y gcc-9 g+±9
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 900 --slave /usr/bin/g++ g++ /usr/bin/g+±9
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g+±7

filesets:
 stdlibs:
  - usr/lib/x86_64-linux-gnu/libstdc++.so.6.*
stage:
  - $stdlibs
override-stage: |
  snapcraftctl stage
  # below not working, read only file sysem
  #cp /usr/lib/x86_64-linux-gnu/libstdc++.so.* $SNAP/usr/lib/x86_64-linux-gnu/

Thank you for help
Andreas

1 Like

Libraries needed by the snap should be in the snap. So you should be able to put it in the lib or usr/lib/(arch-triplet)/ folder. Then set the LD_LIBRARY_PATH environment variable for your application to look there first. For example:

apps:
  foo:
    command: foo
    environment:
      LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/:$LD_LIBRARY_PATH

Or similar.

I always get
/snap/frm2-charm/x13/usr/local/bin/charm: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26’ not found

inside snapbuild I get

snapcraft-frm2-charm # find / -name libstdc++.so.*
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
/snap/core18/1754/usr/lib/x86_64-linux-gnu/libstdc++.so.6
/snap/core18/1754/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25

I would expect the problem to be solved by copying the 2 files from /usr/lib to /snap/core18/1754

How can I achieve this ?

parts:
gcc-9:
plugin: nil
override-pull: |
add-apt-repository -yu ppa:ubuntu-toolchain-r/test
apt install -y gcc-9 g+±9
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 900 --slave /usr/bin/g++ g++ /usr/bin/g+±9
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 700 --slave /usr/bin/g++ g++ /usr/bin/g+±7

filesets:
 stdlibs:
  - usr/lib/x86_64-linux-gnu/libstdc++.so.6
  - usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28
stage:
  - $stdlibs
override-stage: |
  snapcraftctl stage
 # cp /usr/lib/x86_64-linux-gnu/libstdc++.so.* $SNAP/usr/lib/x86_64-linux-gnu/

apps:
frm2-charm:
command: bin/charm
plugs: [home, network, network-bind]
environment:
LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/:$LD_LIBRARY_PATH