gpt4 book ai didi

c++ - 运行 C++11 程序

转载 作者:行者123 更新时间:2023-11-28 06:18:20 25 4
gpt4 key购买 nike

我在 scientific linux 中安装了 gcc4.8:

wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
yum install devtoolset-2

gcc --version gives me: gcc4.8

现在我的问题是当我现在在 gcc 上运行 C++11 程序时(使用 netbeans IDE)我得到错误:

/home/topK/CppApplication_7/dist/Debug/GNU-Linux-x86/cppapplication_7: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.17' not found (required by /home/topK/CppApplication_7/dist/Debug/GNU-Linux-x86/cppapplication_7)
/home/topK/CppApplication_7/dist/Debug/GNU-Linux-x86/cppapplication_7: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.14' not found (required by /home/topK/CppApplication_7/dist/Debug/GNU-Linux-x86/cppapplication_7)
/home/topK/CppApplication_7/dist/Debug/GNU-Linux-x86/cppapplication_7: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /home/topK/CppApplication_7/dist/Debug/GNU-Linux-x86/cppapplication_7)

谁能帮我解决这个错误。

编辑:找到 libstdc++输出:

/usr/lib/libstdc++-3-libc6.2-2-2.10.0.so
/usr/lib/libstdc++-libc6.2-2.so.3
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libstdc++.a
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/libstdc++.so
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libstdc++.a
/usr/lib/gcc/x86_64-redhat-linux/4.4.4/32/libstdc++.so
/usr/lib64/libstdc++.so.5
/usr/lib64/libstdc++.so.5.0.7
/usr/lib64/libstdc++.so.6
/usr/lib64/libstdc++.so.6.0.13
/usr/share/doc/libstdc++-devel-4.4.7
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-1998.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-1999.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2000.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2001.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2002.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2003.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2004.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2005.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2006.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog-2007.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog.bz2
/usr/share/doc/libstdc++-devel-4.4.7/ChangeLog~.bz2
/usr/share/doc/libstdc++-devel-4.4.7/README
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib/libstdc++.so.6.0.13-gdb.pyo
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.py
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyc
/usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.13-gdb.pyo
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/checksum_data
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/checksum_type
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/from_repo
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/from_repo_revision
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/from_repo_timestamp
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/installed_by
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/reason
/var/lib/yum/yumdb/c/32df1c3f56009c7df737dd4bfbd327bb0aef8d6e-compat-libstdc++-296-2.96-144.el6-i686/releasever
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/checksum_data
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/checksum_type
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/from_repo
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/from_repo_revision
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/from_repo_timestamp
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/installed_by
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/reason
/var/lib/yum/yumdb/c/a34683059a40d1d3401aab2723d7b68c8e1cbe15-compat-libstdc++-33-3.2.3-69.el6-x86_64/releasever
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/changed_by
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/checksum_data
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/checksum_type
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/command_line
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/from_repo
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/from_repo_revision
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/from_repo_timestamp
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/installed_by
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/reason
/var/lib/yum/yumdb/l/cd38d7a96e461667eb9113f1fddb8a1e43d94178-libstdc++-4.4.7-11.el6-x86_64/releasever
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/changed_by
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/checksum_data
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/checksum_type
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/command_line
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/from_repo
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/from_repo_revision
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/from_repo_timestamp
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/installed_by
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/reason
/var/lib/yum/yumdb/l/d804bf01331824c1a148301bc5102dd7276e5136-libstdc++-devel-4.4.7-11.el6-x86_64/releasever

编辑:找到 g++输出:

/opt/rh/devtoolset-2/root/usr/bin/g++
/opt/rh/devtoolset-2/root/usr/bin/x86_64-redhat-linux-g++
/opt/rh/devtoolset-2/root/usr/share/man/man1/g++.1.gz
/usr/bin/g++
/usr/bin/x86_64-redhat-linux-g++
/usr/lib64/libconfig++.so.8
/usr/lib64/libconfig++.so.8.0.0
/usr/share/man/man1/g++.1.gz

最佳答案

我的猜测是 /usr/lib64/libstdc++.so 是您的应用程序试图链接到的较旧的库...而较新的库安装在其他地方,但不在搜索路径——或者如果它在搜索路径上,它位于旧库之后,这就是链接器尝试链接旧库但失败的原因。

尝试这样做:

$ g++ program.cpp -L/path/to/new/stdlib -lstdc++ -Wl,-rpath=/path/to/new/stdlib

其中 /path/to/new/stdlib 是新库的位置。您也可以在 LD_LIBRARY_PATH 的开头设置它。


或者

您正在使用旧版本的 g++,并试图对抗新版本的 libstdc++.so。找到 g++ 并使用它。使用 g++libstdc++ 的所有 4 种组合(如果它们各自有两个版本)。

希望对您有所帮助。

关于c++ - 运行 C++11 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29805852/

25 4 0
文章推荐: swift - 加速度计的正确使用方法
文章推荐: html - 格式化网页问题
文章推荐: ios - 从 Array Swift 3 向 Core Data 添加数据
文章推荐: css - 在移动设备上呈现的普通