Steg Verner
Steg Verner

Reputation: 913

Running C++11 programs

I installed gcc4.8 in scientific linux using:

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

Now my problem is when I now run C++11 programs on gcc (using netbeans IDE) I get the error:

/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)

Can someone please help me as to how can I get rid of this error.

EDIT: locate libstdc++ OUTPUT:

/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

EDIT: locate g++ OUTPUT:

/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

Upvotes: 0

Views: 366

Answers (1)

Sarfaraz Nawaz
Sarfaraz Nawaz

Reputation: 361612

My guess is that /usr/lib64/libstdc++.so is the older library which your application is trying to link against... and the newer library is installed somewhere else, which is not on the search path — or if it is on the search path, it comes after the old library, which is why the linker attempts to link against the older one, and fails.

Try doing this:

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

where /path/to/new/stdlib is the location of the new library. You can also set this on the beginning of LD_LIBRARY_PATH.


Or

You're using older version of g++, and trying to against the newer version of libstdc++.so. Locate g++ and use it. Use all 4 combinations of g++ and libstdc++ (if there are two versions of each of them).

Hope that helps.

Upvotes: 1

Related Questions