There isn't actually a package called libstdc++ (possibly you are trying to install libstdc++6?)

When apt doesn't find an exact match to a package name, it treats the given string as a regular expression. In this case the ++ causes it to try to install any package whose name matches libstd followed by one or more c - many of which conflict, as you can see.

Unfortunately I have never managed to figure out how to turn off this behaviour (nothing I have tried in the past using escape characters has seemed to work) - the only solution I know is to be careful to give an exact package name where any regex characters might be misinterpreted, and to make sure the package catalog is up-to-date i.e.

sudo apt-get update
sudo apt-get install libstdc++6
Answer from steeldriver on askubuntu.com
🌐
MIT
web.mit.edu › darwin › src › modules › gcc3 › libstdc++-v3 › docs › html › install.html
libstdc++-v3 Installation Instructions
The generated g++ will magically use the correct headers, link against the correct library binary, and in general using libstdc++-v3 will be a piece of cake. You're done; run 'make install' (see the GCC installation instructions) to put the new compiler and libraries into place.
Discussions

c++ - How do I install a libstdc++ that I just built as part of gcc? - Stack Overflow
I built and installed gcc 4.8.2 on my system a few months ago. Today I used it to compile a program that uses the C++11 thread library, and when I ran it, it complained that the proper version of l... More on stackoverflow.com
🌐 stackoverflow.com
How to update libstdc++6 in Ubuntu?
Upgrade to 24.04. More on reddit.com
🌐 r/linux4noobs
5
1
July 12, 2024
c++ - How to install libstdc++6 debug symbols on Ubuntu 20.04? - Stack Overflow
However, as soon as you succeed installing the debug info packages, everything else is set up nicely, even the source files! You can s step into e.g. abort() and list around the source code! ... You have to find the exact version of your libstdc++.so.xxx and install the corresponding debug ... More on stackoverflow.com
🌐 stackoverflow.com
ubuntu - Why doesn't apt-get install the latest version of libstdc++6? - Stack Overflow
I have a problem where the installation associated with apt-get is a different version than conda, causing problems when loading python packages. sudo find / -name "libstdc++.so*" /opt/c... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GNU
gcc.gnu.org › onlinedocs › libstdc++ › manual › setup.html
Chapter 2. Setup
Building libstdc++ separately from the rest of GCC is not supported. The general outline of commands to build GCC is something like: get gcc sources extract into gccsrcdir mkdir gccbuilddir cd gccbuilddir gccsrcdir/configure --prefix=destdir --other-opts... make make check make install
🌐
Stack Overflow
stackoverflow.com › questions › 23451159 › how-do-i-install-a-libstdc-that-i-just-built-as-part-of-gcc
c++ - How do I install a libstdc++ that I just built as part of gcc? - Stack Overflow
I built and installed gcc 4.8.2 on my system a few months ago. Today I used it to compile a program that uses the C++11 thread library, and when I ran it, it complained that the proper version of libstdc++ could not be found. So I went back into the gcc 4.8.2 source tree and manually copied libstdc++-6.0.18 into the appropriate location.
🌐
Reddit
reddit.com › r/linux4noobs › how to update libstdc++6 in ubuntu?
r/linux4noobs on Reddit: How to update libstdc++6 in Ubuntu?
July 12, 2024 -

Hi,

I have an app which tells me I need GLIBCXX_3.4.31

After doing my own research I tried to update libsdc++6 through

sudo apt install libsdc++6

Did apt update too

When I strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX it shows 3.4.30 as the latest version.

I tried some stuff found on the internet but I can't wrap my head around it as nothing works.

What am I doing wrong?

edit: Ubuntu 22.04.4 LTS, virtualbox

Top answer
1 of 3
6

Background Story

Days ago, I was also curious about the same question as yours. But that's on CentOS.

What can I do differently after I install those missing debug info packages for gdb?

You can check the question to see what I learnt during searching, I solve your question with those prior knowledge.

In short, for the same thing, in CentOS the difficulties come down to installing the debug info packages. Because the gdb in CentOS tells what exact version of some debug info files you need to install and it gives the full command.

debuginfo-install glibc-2.17-307.el7.1.x86_64 libgcc-4.8.5-44.el7.x86_64 libstdc++-4.8.5-44.el7.x86_64

But this command just can't work and you need to manually add some package sources to install that .

However, as soon as you succeed installing the debug info packages, everything else is set up nicely, even the source files! You can s step into e.g. abort() and list around the source code!

In Ubuntu:

  1. You have to find the exact version of your libstdc++.so.xxx and install the corresponding debug info files.

  2. No library (e.g. libstdc++) source files will be installed and set up after install the corresponding debug info files packages. But you can manually do it with set substitute-path.

Answer Part

I made my gdb work under Ubuntu 18.04.5 LTS. I think that may applies to yours too.

  1. I assume you know this https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html .

So firstly I ldd my.a.out.

libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fbfa6f84000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fbfa697b000)
...

In my Ubuntu, reading debug symbol for libc.so.6 is successful. So I want to check both .so files' .gnu_debuglink section.

libc.so.6 is a link to libc-2.27.so

so I read the above section with readelf -x.gnu_debuglink libc-2.27.so and gives me:

Hex dump of section '.gnu_debuglink':
  0x00000000 6c696263 2d322e32 372e736f 00000000 libc-2.27.so....
  0x00000010 32e033a0                            2.3.

This means its debug info file's name is libc-2.27.so, which exists in /usr/lib/debug/lib/x86_64-linux-gnu directory.

Now check libstdc++.so.6, which is a link to libstdc++.so.6.0.25 in my machine.

readelf -x.gnu_debuglink libstdc++.so.6.0.25 gives:

Hex dump of section '.gnu_debuglink':
  0x00000000 31313961 34346139 39373538 31313436 119a44a997581146
  0x00000010 32306338 65396438 65323433 64373039 20c8e9d8e243d709
  0x00000020 34663737 66362e64 65627567 00000000 4f77f6.debug....
  0x00000030 30573da0                            0W=.

This 119a44a99758114620c8e9d8e243d7094f77f6.debug is a build-id debug file.

  1. Learnt from your question and comments below, I do dpkg --list | grep libstdc++ and shows
ii  libstdc++-7-dev:amd64                      7.5.0-3ubuntu1~18.04                             amd64        GNU Standard C++ Library v3 (development files)
ii  libstdc++-8-dev:amd64                      8.4.0-1ubuntu1~18.04                             amd64        GNU Standard C++ Library v3 (development files)
ii  libstdc++6:amd64                           8.4.0-1ubuntu1~18.04                             amd64        GNU Standard C++ Library v3
ii  libstdc++6:i386                            8.4.0-1ubuntu1~18.04                             i386         GNU Standard C++ Library v3

So I sudo apt install libstdc++6-8-dbg.

Then I used dpgk-query -L libstdc++6-8-dbg to see what files are installed with this packages.

tianhe@tianhe-windy:/lib/x86_64-linux-gnu$ dpkg -L libstdc++6-8-dbg
/.
/usr
/usr/lib
/usr/lib/debug
/usr/lib/debug/.build-id
/usr/lib/debug/.build-id/f2
/usr/lib/debug/.build-id/f2/119a44a99758114620c8e9d8e243d7094f77f6.debug
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/debug
/usr/lib/x86_64-linux-gnu/debug/libstdc++.a
/usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6.0.25
/usr/lib/x86_64-linux-gnu/debug/libstdc++fs.a
/usr/share
/usr/share/doc
/usr/share/gdb
/usr/share/gdb/auto-load
/usr/share/gdb/auto-load/usr
/usr/share/gdb/auto-load/usr/lib
/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu
/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/debug
/usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6.0.25-gdb.py
/usr/lib/x86_64-linux-gnu/debug/libstdc++.so
/usr/lib/x86_64-linux-gnu/debug/libstdc++.so.6
/usr/share/doc/libstdc++6-8-dbg

And I think I got the debug files when I saw this line:

/usr/lib/debug/.build-id/f2/119a44a99758114620c8e9d8e243d7094f77f6.debug.

Then I open gdb again and it works. I can now s step into string s = "hello";.

So try check what I describe above see if they match.

2 of 3
6

I followed these instructions https://www.hiroom2.com/ubuntu-2004-dbgsym-en/.

Adding the debug symbols repo:

#!/bin/sh -e

U=http://ddebs.ubuntu.com
C=$(lsb_release -cs)

cat <<EOF | sudo tee /etc/apt/sources.list.d/ddebs.list
deb {C} main restricted universe multiverse
#deb {C}-security main restricted universe multiverse
deb {C}-updates main restricted universe multiverse
deb {C}-proposed main restricted universe multiverse
EOF

wget -O - http://ddebs.ubuntu.com/dbgsym-release-key.asc | \
    sudo apt-key add -

sudo apt update -y

Then install symbols for libstdc++6

sudo apt-get install libstdc++6-dbgsym
🌐
LinuxQuestions.org
linuxquestions.org › questions › red-hat-31 › installing-libstdc-so-5-a-4175537589
[SOLVED] Installing libstdc++.so.5
March 23, 2015 - Hi I have to intall a software for monitoring on our Red Hat Linux 6 Server and it seems to miss the libstdc++.so.5. After some googling I found that
Find elsewhere
🌐
IBM
ibm.com › docs › en › tip › 2.2.0
Setting the libstdc++ level for Linux systems - IBM Documentation
March 8, 2021 - The Deployment Engine component does not support libstdc++.so.6 or higher on Linux systems. Your Tivoli Integrated Portal installation may fail on Linux systems if the libstdc++ level is at /usr/lib/libstdc++.so.6 or higher.
🌐
Linux From Scratch
linuxfromscratch.org › lfs › view › development › chapter05 › gcc-libstdc++.html
5.6. Libstdc++ from GCC-16.1.0
../libstdc++-v3/configure \ --host=$LFS_TGT \ --build=$(../config.guess) \ --prefix=/usr \ --disable-multilib \ --disable-nls \ --disable-libstdcxx-pch \ --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/16.1.0 ... Specifies that the cross-compiler we have just built should be used instead of the one in /usr/bin. ... This switch prevents the installation of precompiled include files, which are not needed at this stage.
🌐
Stack Overflow
stackoverflow.com › questions › 73842407 › why-doesnt-apt-get-install-the-latest-version-of-libstdc6
ubuntu - Why doesn't apt-get install the latest version of libstdc++6? - Stack Overflow
I can fix this by manually copying the files from /opt/conda/lib to /usr/lib/. However, I believe the recommended solution is to install the latest version of the package with apt-get. ... sudo apt-get update & sudo apt-get upgrade libstdc++6 Hit:1 http://security.debian.org/debian-security bullseye-security InRelease Hit:2 http://deb.debian.org/debian bullseye InRelease Hit:3 http://deb.debian.org/debian bullseye-updates InRelease Reading package lists...
🌐
Red Hat
access.redhat.com › discussions › 5973261
Red Hat Customer Portal - Access to 24x7 support and knowledge
Hi All, How can I install libstdc++.so.5 in Rhel 8.3? Best regards, Marben · by · points · LinkedIn · YouTube · Facebook · X, formerly Twitter · Downloads · Subscriptions · Support Cases · Customer Service · Product Documentation · Contact Us · Customer Portal FAQ ·
🌐
DLLme
dllme.com › dll › files › libstdc_-6
libstdc++-6.dll : Free .DLL Download
December 29, 2025 - Download and install libstdc++-6.dll to fix missing or corrupted DLL errors.
🌐
GNU
gcc.gnu.org › onlinedocs › libstdc++ › faq.html
Frequently Asked Questions
2.2. So any program which uses libstdc++ falls under the GPL? 2.3. How is that different from the GNU {Lesser,Library} GPL? 2.4. I see. So, what restrictions are there on programs that use the library? 3.1. How do I install libstdc++? 3.2. How does one get current libstdc++ sources?
🌐
Commandfound
commandfound.com › post › libstdc++lib-not-found-ubuntu
How to Install libstdc++ Library on Ubuntu - CommandFound
April 5, 2024 - Learn how to install the libstdc++ library on Ubuntu and understand its importance in software development.
🌐
Stack Exchange
unix.stackexchange.com › questions › 277483 › installing-libstdc-devel-on-my-centos-server
software installation - Installing libstdc++-devel on my CentOS server - Unix & Linux Stack Exchange
April 19, 2016 - rpm -qa | grep libstdc++ gives: libstdc++-4.8.3-9.el7.x86_64 However, find . -name "*libstdc++*" gives: ./usr/lib/gcc/x86_64-redhat-linux/4.8.2/32/libstdc++.a ./usr/lib/gcc/x86_64-redhat-linux/4...