1

Trying to compile dotnet code on ubuntu and get this error:

Failed to load /usr/lib/dotnet/dotnet6-6.0.109/host/fxr/6.0.9/libhostfxr.so, error: /home/ubuntu/anaconda3/lib/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /usr/lib/dotnet/dotnet6-6.0.109/host/fxr/6.0.9/libhostfxr.so) The library libhostfxr.so was found, but loading it from /usr/lib/dotnet/dotnet6-6.0.109/host/fxr/6.0.9/libhostfxr.so failed

dotnet --version and dotnet --info do not work.

How do I fix this?

HNN
  • 11
  • Are you sure you want to be linking /home/ubuntu/anaconda3/lib/libstdc++.so.6 instead of the system's libstdc++.so.6? – steeldriver Sep 24 '22 at 13:12
  • I did not link anything. I have this error and I can not use dotnet 6. What do I need to do? – HNN Sep 24 '22 at 14:14
  • How did you install dotnet6 on your system? I just followed through the installation steps for 22.04 in the link that you shared in your question and it worked fine on my system. – Terrance Sep 24 '22 at 14:53
  • I believe that I use the script here: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install I am not sure though. It was working fine until I did one of ubuntu's system updates. – HNN Sep 24 '22 at 15:20
  • 1
    That installer only covers up to 18.04, so it may not have installed the correct version into your installation. You might need to install the dotnet from the repos by following the installation steps at https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu But you will probably need to remove the existing installation by running dpkg -l | grep dotnet then doing sudo apt remove <dotnetname> listed by dpkg. – Terrance Sep 25 '22 at 00:04

1 Answers1

0

Update your repositories and install build-essential, which contains GCC, inter alia:

sudo apt update
sudo apt install build-essential

This package depends on g++, which depends on g++-11, which depends on libstdc++-11-dev, which depends on libstdc++6, the package you desire.

You should have thus installed a shared object of the GNU standard C++ library at /usr/lib/x86_64-linux-gnu/libstdc++.so.6. Run the following commands to see the supported versions and which version it points to:

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX
ls -la /usr/lib/x86_64-linux-gnu/libstdc++.so.6

Update the symbolic link as needed. Install an older version of the GCC toolchain if necessary. Godspeed.

Originally posted here: https://stackoverflow.com/questions/73836387/how-to-fix-glibcxx-3-4-30-not-found-in-ubuntu-22-04