Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

how to make icc use different version of libstdc++?

ningyushi
Beginner
307 Views
I have both g++4.2 & g++4.1 installed on the system, since icc isn't compatiable with g++4.2's stl, so I want to use g++4.1's stl. The include file is in /usr/include/c++/4.1 but I don't know how to make icc to use the 4.1 version include file & link with the corresponding library file. -cxx-lib doesn't work for me, since that requires the whole version of g++-4.1 installed in a spcecifc directory where in my system they are scattered in /usr/lib & /usr/include etc.
Anybody know how to do this? thanks
0 Kudos
2 Replies
TimP
Honored Contributor III
307 Views
I assume you are using icc 9.1 or later, so as to have compatibility with g++ 4.1. Then you set your PATH so as to put the g++ 4.1 installation ahead of the other, e.g. supposing you installed it in /usr/local/gcc41/
export PATH=/usr/local/gcc41/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/gcc41/lib:$LD_LIBRARY_PATH
Your g++ 4.1 must be a working installation, such that
g++ -print-search-dirs
shows where g++ finds its library and include files.
0 Kudos
muntyan
Beginner
307 Views
It won't work if gcc isn't installed in a separate prefix. E.g. here on Debian (and I believe the OP has similar setup), all gcc are installed in /usr:

/usr/bin/gcc -> /usr/bin/gcc-4.2
/usr/bin/gcc-4.1
/usr/bin/gcc-4.2
/usr/lib/gcc/i486-linux-gnu/4.1.2/
/usr/lib/gcc/i486-linux-gnu/4.2/

Installing yet another gcc from source is possible of course, but it'd be extra pain :(

For what it's worth, I have this wrapper script as "icpc":

#!/bin/sh
PATH=/usr/local/lib/icc/fake-gcc:$PATH
. /usr/local/lib/icc/bin/iccvars.sh
exec /usr/local/lib/icc/bin/icpc $@

fake-gcc is a directory which contains symlinks g++ -> /usr/bin/g++-4.1, etc.
0 Kudos
Reply