×

Search anything:

[FIXED] /usr/lib/libstdc++.so.6: version 'GLIBCXX_3.4.16' not found

Binary Tree book by OpenGenus

Open-Source Internship opportunity by OpenGenus for programmers. Apply now.

In this article, we have explored the cause of the error "/usr/lib/libstdc++.so.6: version 'GLIBCXX_3.4.16' not found" and presented 3 fixes to resolve this runtime error.

Table of contents:

  1. Error
  2. Fix 1: Place correct Glibc in Path
  3. Fix 2: Build correct GCC version
  4. Fix 3: Static linking

Error

While running a compiled code, you may face this runtime error:

/usr/lib/libstdc++.so.6: version 'GLIBCXX_3.4.15' not found

The issue is the code is linking to the wrong Glibc version. The cause could be that the code was compiled using a different GCC version on another system and while running on another system, the required Glibc version is not available.

This problem can also, arise if you have multiple GCC versions in your system. Note Glibc can be installed separately but also, comes with GCC. A specific GCC version comes with only a set of specific Glibc versions.

Fix 1: Place correct Glibc in Path

One of the common reason is that during runtime, the executable is linking to the wrong libstdc++.so. Often, the software comes with its own Glibc which may be the correct version or not.

For example, this path has an alternative libstdc++.so file:

/gcc/trunk/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.17

The original file is in /usr/lib64 directory.

We can set the path to the new so file in LD_LIBRARY_PATH as follows:

export LD_LIBRARY_PATH=/gcc/trunk/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/

Or, copy the new so file to the correct location and create a softlink:

cd /usr/lib64 
rm libstdc++.so.6
cp /gcc/trunk/x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6.0.17 .
ln -s libstdc++.so.6.0.17 libstdc++.so.6

This will enable the executable to link to the correct so file.

Fix 2: Build correct GCC version

strings /usr/lib/libstdc++.so.6 | grep GLIBC

Get Glibc version: 3.4.15

Following is the list of Glibc version and the corresponding GCC version:

  • GCC 3.1.0: GLIBCPP_3.1
  • GCC 3.1.1: GLIBCPP_3.1
  • GCC 3.2.0: GLIBCPP_3.2
  • GCC 3.2.1: GLIBCPP_3.2.1
  • GCC 3.2.2: GLIBCPP_3.2.2
  • GCC 3.2.3: GLIBCPP_3.2.2
  • GCC 3.3.0: GLIBCPP_3.2.2
  • GCC 3.3.1: GLIBCPP_3.2.3
  • GCC 3.3.2: GLIBCPP_3.2.3
  • GCC 3.3.3: GLIBCPP_3.2.3
  • GCC 3.4.0: GLIBCXX_3.4
  • GCC 3.4.1: GLIBCXX_3.4.1
  • GCC 3.4.2: GLIBCXX_3.4.2
  • GCC 3.4.3: GLIBCXX_3.4.3
  • GCC 4.0.0: GLIBCXX_3.4.4
  • GCC 4.0.1: GLIBCXX_3.4.5
  • GCC 4.0.2: GLIBCXX_3.4.6
  • GCC 4.0.3: GLIBCXX_3.4.7
  • GCC 4.1.1: GLIBCXX_3.4.8
  • GCC 4.2.0: GLIBCXX_3.4.9
  • GCC 4.3.0: GLIBCXX_3.4.10
  • GCC 4.4.0: GLIBCXX_3.4.11
  • GCC 4.4.1: GLIBCXX_3.4.12
  • GCC 4.4.2: GLIBCXX_3.4.13
  • GCC 4.5.0: GLIBCXX_3.4.14
  • GCC 4.6.0: GLIBCXX_3.4.15
  • GCC 4.6.1: GLIBCXX_3.4.16
  • GCC 4.7.0: GLIBCXX_3.4.17
  • GCC 4.8.0: GLIBCXX_3.4.18
  • GCC 4.8.3: GLIBCXX_3.4.19
  • GCC 4.9.0: GLIBCXX_3.4.20
  • GCC 5.1.0: GLIBCXX_3.4.21
  • GCC 6.1.0: GLIBCXX_3.4.22
  • GCC 7.1.0: GLIBCXX_3.4.23
  • GCC 7.2.0: GLIBCXX_3.4.24
  • GCC 8.1.0: GLIBCXX_3.4.25
  • GCC 9.1.0: GLIBCXX_3.4.26
  • GCC 9.2.0: GLIBCXX_3.4.27
  • GCC 9.3.0: GLIBCXX_3.4.28
  • GCC 10.1.0: GLIBCXX_3.4.28
  • GCC 11.1.0: GLIBCXX_3.4.29
  • GCC 12.1.0: GLIBCXX_3.4.30
  • GCC 13.1.0: GLIBCXX_3.4.31

So, if your system has GLibc version 3.4.29, you need to use GCC version 11.1.0 and compile your code using this GCC to avoid this error.

You can follow these steps to install GCC of any version.

Fix 3: Static linking

An easy fix is to try to link to the so file statically using the following compilation flag:

-static-libstdc++

By default, it will try to link dynamically.

The command will be like:

gcc code.c -static-libstdc++

With these fixes in this article at OpenGenus, you must have fixed this runtime error easily.

Geoffrey Ziskovin

Geoffrey Ziskovin

Geoffrey Ziskovin is an American Software Developer and Author with an experience of over 30 years. He started his career with Haskell and has interviewed over 700 candidates for Fortune 500 companies

Read More

Improved & Reviewed by:


OpenGenus Tech Review Team OpenGenus Tech Review Team
[FIXED] /usr/lib/libstdc++.so.6: version 'GLIBCXX_3.4.16' not found
Share this