How to tell icc to use specific gcc c++ header file on Linux?

How to tell icc to use specific gcc c++ header file on Linux?

Hi, everyone
I have 2 versions of gcc installed on my system: gcc-4.2.2-1 installed on /usr/local and gcc-4.1.2 installed on /usr. When i use icc compile my c code, as if it always uses c++ header files from gcc-4.2.2-1. But i want to my icc use all the c/c++ header files and libs from gcc-4.1.2, How can i do it for icc???


7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


the following options can help you:

-gcc-version=XYZ (e.g. XYZ=412 in your case)

The two *name options are required to find the GNU compiler binaries. The version is required to make the Intel compiler use the correct ABI and compatibility settings (this one is optional).

Best regards,

Georg Zitzlsberger

I have tried those options. It seems they do not work. Because i call my icc from nVidia nvcc, i set the option as follows:
nvcc -c -ccbin icc -Xcompiler -gcc-version=412
It still report me that icc go to gcc-4.2.2 to find some C++ header files and libs. Since i have to use nvcc and icc together and nvcc only supports gcc-4.1.2, there must be some other ways to change the settings of icc.


the option "-gcc-version=XYZ" is optional. You should use "-gcc-name=..." and "-gxx-name=..." in first place.
You might also use option "-dryrun" to find out whether the options got forwarded correctly.

Please let me know if this works for you.

Best regards,

Georg Zitzlsberger

It should also be sufficient to change your PATH so that g++-4.1 comes ahead of other gcc/g++ installations; then 'g++ -version' or 'g++ -print-search-dirs' will verify your setup. On some linux installations, the default search order between /usr/bin and /usr/local/ changes, depending on your login route.
I prefer to install current gcc in a specific path such as /usr/local/gcc-4.7/ so that it comes on PATH only when I take such action explicitly.
Depending on such an old gcc becomes increasingly difficult, as gcc-4.4 is the oldest one in use on recently released linux distros.

Two versions GCC/++ versions or more could be installed in the same directory /usr (prefix)
In /usr/bin you have several version gcc-x.x ad g++-.x.x
If you want that Intel compiler take specific an version of Gnu compiler you must link or copy
the name complete of specific version on short name are same gcc and g++.

cp /usr/bin/gcc-4.2.2-1 /usr/bin/gcc (icc understand gcc-4.2.2-1 is your gnu compiler)
cp /usr/bin/g++-4.2.2-1 /usr/bin/g++ (icc understand g++-4.2.2-1 is your gnu compiler)

cp /usr/bin/gcc-4.1.2 /usr/bin/gcc (icc understand gcc-4.1.2 is your gnu compiler)
cp /usr/bin/g++-4.1.2 /usr/bin/g++ (icc understand g++-4.1.2 is your gnu compiler)

With an secondary path repertory (/usr/local) you add a complexity for nothing...
Do not worry the two versions of compiler are completely dissociated
even in unique directory (/usr/bin)
Install the 3 types of version GNU compiler of your distibution you see that the all loader are in /usr/bin

I think,you have now versions more recent that your gcc-4.2.2-1 that could working
largely better ...
Also on the recent version GNU & ICC you have now new linker (elf,gold) for (IPO / LTO)
and several new options that are very performant..

(Always interupted !!!),I finish by step

Refer to this example of an computer in my hand (flags are in bold)
showing where is the path and the specific name ,could be determinate

g++ -v
Using built-in specs.
Target: i486-linux-gnu

Configured with: ../src/configure -v --enable-languages=c,c++,go,fortran,
objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/
--enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object
--enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu

Thread model: posix
gcc version 4.7.1 (Debian 4.7.1-2)

Now if i want build new compiler dissociated (example with added Cloog flag) and preserving
the original I must change only -4.7 example: (-4.7.last)


Hi, everyone,Thanks for your kind advice
I just find there is an environmental variable GXX_ROOT ,which points to gcc-4.2.2, in my computer.
Changing this variable to a specific version of gcc solves my problem.
Thanks all

Leave a Comment

Please sign in to add a comment. Not a member? Join today