当我尝试在 Ubuntu bash 中运行我的程序时,出现此错误:" /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21

When I try to run my program in Ubuntu bash I get this error : " /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.21' not found "

本文关键字:x86 64-linux-gnu lib usr libstdc++ so GLIBCXX version 错误 Ubuntu bash      更新时间:2023-10-16
当我在 bash:"export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/

usr/local/lib64:/usr/lib64"中输入这个命令时,我的程序开始工作,但是每次开始使用终端时,我都必须在 bash 中输入这个命令,这很麻烦。谁能帮我永久解决这个问题

@kfsone libstdc++.so.6.0.21-gdb.py,在这个文件中:

import sys
import gdb
import os
import os.path
pythondir = '/usr/share/gcc-5.3.0/python'
libdir = '/usr/lib/../lib32'
# This file might be loaded when there is no current objfile.  This
# can happen if the user loads it manually.  In this case we don't
# update sys.path; instead we just hope the user managed to do that
# beforehand.
if gdb.current_objfile () is not None:
    # Update module path.  We want to find the relative path from libdir
    # to pythondir, and then we want to apply that relative path to the
    # directory holding the objfile with which this file is associated.
    # This preserves relocatability of the gcc tree.
    # Do a simple normalization that removes duplicate separators.
    pythondir = os.path.normpath (pythondir)
    libdir = os.path.normpath (libdir)
    prefix = os.path.commonprefix ([libdir, pythondir])
    # In some bizarre configuration we might have found a match in the
    # middle of a directory name.
    if prefix[-1] != '/':
        prefix = os.path.dirname (prefix) + '/'
    # Strip off the prefix.
    pythondir = pythondir[len (prefix):]
    libdir = libdir[len (prefix):]
    # Compute the ".."s needed to get from libdir to the prefix.
    dotdots = ('..' + os.sep) * len (libdir.split (os.sep))
    objfile = gdb.current_objfile ().filename
    dir_ = os.path.join (os.path.dirname (objfile), dotdots, pythondir)
    if not dir_ in sys.path:
        sys.path.insert(0, dir_)
# Call a function as a plain import would not execute body of the included file
# on repeated reloads of this object file.
from libstdcxx.v6 import register_libstdcxx_printers
register_libstdcxx_printers(gdb.current_objfile())

程序所依赖的库当前不在系统检查库的路径中。您可以将其添加到 .bashrc 中的LD_LIBRARY_PATH中,这样您就不必手动设置它 youelrf,或者您可以使用 ldconfig 在系统范围内添加它:

选项 1:编辑/etc/ld.so.conf

选项 2:在/etc/ld.so.conf.d 中创建一个 "locallibs.conf" 文件

无论哪种情况,您都需要两行:

/usr/local/lib
/usr/local/lib64

然后

$ sudo ldconfig