/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8' not found

201,348

Solution 1

Add the library's path to the LD_LIBRARY_PATH environment variable

TL;DR

GCC requires you to tell it where your library is located manually when it can't find the right version, which can be done in a few ways. One is adding it to the LD_LIBRARY_PATH.

export LD_LIBRARY_PATH="/usr/local/lib64/:$LD_LIBRARY_PATH"

For some, the library path will be /usr/local/lib64/. Others have reported the library path /usr/lib/x86_64-linux-gnu/ working for them instead.

Why do we need to add the library to LD_LIBRARY_PATH?

When you compile and install GCC it puts the libraries in one of these directories, but that's all it does. According to the FAQs for libstdc++, the error that we got means that the dynamic linker found the wrong version of the libstdc++ shared library. Because the linker can't find the right version, we have to tell it where to find the libstdc++ library.

The simplest way to fix this is to use the LD_LIBRARY_PATH environment variable, which is a colon-separated list of directories in which the linker will search for shared libraries.

There are other ways as well to fix this issue. You can find this and the other solutions mentioned briefly when you install gcc if you read the make output:

Libraries have been installed in:

/usr/local/lib/../lib32

If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following:

  • add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution
  • add LIBDIR to the `LD_RUN_PATH' environment variable during linking
  • use the `-Wl,-rpath -Wl,LIBDIR' linker flag
  • have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages.

Grr, that was simple! Also, "if you ever happen to want to link against the installed libraries," seriously?

Solution 2

I had the same problem on my Ubuntu 14.04 when tried to install TopTracker. I got such errors:

/usr/share/toptracker/bin/TopTracker: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'CXXABI_1.3.8' not found (required by /usr/share/toptracker/bin/TopTracker) /usr/share/toptracker/bin/TopTracker: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'GLIBCXX_3.4.21' not found (required by /usr/share/toptracker/bin/TopTracker) /usr/share/toptracker/bin/TopTracker: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version 'CXXABI_1.3.9' not found (required by /usr/share/toptracker/bin/TopTracker)

But I then installed gcc 4.9 version and problem gone:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9

Solution 3

I've got correct solution here.

The best way to correctly install gcc-4.9 and set it as your default gcc version use:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9

The --slave, with g++, will cause g++ to be switched along with gcc, to the same version. But, at this point gcc-4.9 will be your only version configured in update-alternatives, so add 4.8 to update-alternatives, so there actually is an alternative, by using:

sudo apt-get install gcc-4.8 g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

Then you can check which one that is set, and change back and forth using:

sudo update-alternatives --config gcc

NOTE: You could skip installing the PPA Repository and just use /usr/bin/gcc-4.9-base but I prefer using the fresh updated toolchains.

Solution 4

In my case it was gcc 6 the one missing

sudo apt-get install gcc-6 g++-6 -y 

Update

sudo apt-get install gcc-7 g++-7 -y

Solution 5

This solution work on my case i am using ubuntu 16.04, VirtualBox 2.7.2 and genymotion 2.7.2 Same error come in my system i have followed simple step and my problem was solve

1. $ LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH
2. $ export LD_LIBRARY_PATH
3. $ sudo apt-add-repository ppa:ubuntu-toolchain-r/test
4. $ sudo apt-get update
5. $ sudo apt-get install gcc-4.9 g++-4.9

I hope this will work for you

Share:
201,348

Related videos on Youtube

Alec Teal
Author by

Alec Teal

Updated on July 08, 2022

Comments

  • Alec Teal
    Alec Teal almost 2 years

    It turns out that "make install" - the make target that installs and implies the target "install-target-libstdc++v3" doesn't actually mean you're ready to go.

    I've been stuck for a while wondering what I was doing wrong because I assumed that such a make target would do that for me.

    • Yuliia Ashomok
      Yuliia Ashomok almost 8 years
      sudo apt-get install gcc-4.9
    • bronze man
      bronze man over 5 years
      If you are the programer that compiler the the program, you can add -static to the gcc command line to static link your program. see: stackoverflow.com/questions/13636513/…
    • Owen
      Owen about 5 years
      I vote to reopen: this is the top google result for this error message, so having the answers frozen is a real disadvantage.
    • Alec Teal
      Alec Teal about 5 years
      @Owen it's actually been closed several times - IIRC this was my third posting (seriously) - however the error and the "fix" on this page are not really properly dealt with here. Just a specific case yielding the error.
  • Zan Lynx
    Zan Lynx over 10 years
    You generally don't want to link against random versions of libraries that you just installed. Your software will not run on any other machine. It is usually better to use the older versions of the libraries that are included with your operating system. If you do need to build libraries then you'll have to include all of them when distributing your software. And if your software is another library which is linked to yet another library which is using a third version of libstdc++ then your program is just not going to work.
  • Alec Teal
    Alec Teal over 10 years
    @ZanLynx isn't that the point of the .x.y.z we have? So it's not random? I suppose not everything specifies a version (hence the default symlink) right?
  • cxrodgers
    cxrodgers over 9 years
    What if the directory /usr/local/lib64 does not exist? I do have libstdc++6 and gcc 4.8 installed.
  • Alec Teal
    Alec Teal over 9 years
    @cxrodgers then just lib, I assumed you'd have a 64bit system
  • cxrodgers
    cxrodgers over 9 years
    I do have a 64-bit system. I get the same error no matter whether I add /usr/local/lib or /usr/local/lib64 (which doesn't even exist) to my path. The library appears to be located at /usr/lib/x86_64-linux-gnu/libstdc++.so.6 but it doesn't help to add this to the path either. Perhaps this needs to be its own question.
  • Alec Teal
    Alec Teal over 9 years
    @cxrodgers then you need to post a question yes
  • Akshay Hazari
    Akshay Hazari almost 7 years
    Doesn't work. Still gives the same error.
  • Britton Kerin
    Britton Kerin over 6 years
    @AlecTeal The problem is that you don't want every program to link against the new lib at run time, which is what LD_LIBRARY_PATH does. See xahlee.info/UnixResource_dir/_/ldpath.html
  • Humayoo
    Humayoo about 6 years
    this work for me. conda install -c anaconda tensorflow
  • o0ragman0o
    o0ragman0o about 6 years
    @AlecTeal Kind of worked but I don't have that /usr/local/lib64, only /usr/local/lib so my program is throwing another error
  • Alec Teal
    Alec Teal about 6 years
    @o0ragman0o are you working with GCC too? Or are you here for the same problem in a different area? I found this in GCC's output (scroll up a bit when it's done) - see hat yours says.
  • o0ragman0o
    o0ragman0o about 6 years
    @AlecTeal ran into it after trying to update an application which turns out to have been compiled in 4.9. I was still on Mint 17 (ubuntu14.04) which has 4.8. Have ended up doing a full upgrade to Mint 18.3 rather than manhandle library paths and such
  • Rishabh Agrahari
    Rishabh Agrahari over 5 years
    what if I don't have sudo access? then how can implement your approach?
  • Lrrr
    Lrrr over 3 years
    As for now, you could use sudo apt-get install gcc-7 g++-7 -y
  • Andria
    Andria over 2 years
    I don't think that /usr/lib/x86_64-linux-gnu/ needs to be its own question. It's just another location and it works just fine, it sounds like @cxrodgers was just accidentally putting the file and not the directory in the path. The following works for me: export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/".