gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 13:20:44 27 4
gpt4 key购买 nike

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

libstdc++.so.6.0.21-gdb.py 中的@kfsone,在此文件内:

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,这样您就不必自己手动设置它,或者您可以使用 ldconfig 在系统范围内添加它:

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

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

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

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

然后

$ sudo ldconfig

关于c++ - 当我尝试在 Ubuntu bash 中运行我的程序时,出现此错误 : "/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version ` GLIBCXX_3. 4.2 1' not found ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35399218/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com