我使用以下方法在科学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
答案 0 :(得分:1)
我的猜测是/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种组合(如果每种都有两个版本)。
希望有所帮助。