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

Use macports gcc

Ilja_H_
Beginner
845 Views

I compile the following program: #include "array" int main() { return 0; } with g++ (from macports) like so: /opt/local/bin/g++-mp-4.8 -std=c++0x a.cpp How can compile the same program with icpc [version 14.0.2 (gcc version 4.2.1 compatibility)]? I tried several things I found via google but nothing seems to work. For example: icpc a.cpp -I /opt/local/include/gcc47/c++ -std=c++11 gives many compilation errors, icpc a.cpp -I /opt/local/include/gcc48/c++ -std=c++11 triggers #if __cplusplus < 201103L #error ... in bits/c++0x_warning.h icpc without additional options gives: a.cpp(1): catastrophic error: cannot open source file "array" #include "array" The default path of /usr/include/c++ should not be used for anything in this case. Is there an easy way to tell icpc which gcc to use or which options should I change from their defaults to make icpc use the correct gcc? Thanks for any help.

And of course rich-text was re-enabled for the captcha thus breaking all my previous formatting without rich-text...

0 Kudos
1 Solution
Sergey_M_Intel
Employee
845 Views

HI Ilya H,

You should pass -gcc-version=470 option to compiler (by default compiler uses another gcc compatibility version).

Also, you should pass correct gcc's include directories to icc compiler. You can determine correct include directories from macports' gcc execution with '-v' argument. gcc will print something like that:

....

 /opt/local/include/gcc48/c++/
 /opt/local/include/gcc48/c++//x86_64-apple-darwin12
 /opt/local/include/gcc48/c++//backward

.....

You should add first two directories to icc command line (with -I prefix, see example below).

 

I've executed (I've got gcc4.8 from macports):

$ icc t.cpp -I /opt/local/include/gcc48/c++/x86_64-apple-darwin12/ -I /opt/local/include/gcc48/c++/ -std=c++11  -gcc-version=480
$ echo $?
0

 

---Sergey

View solution in original post

0 Kudos
9 Replies
TimP
Honored Contributor III
845 Views
Did you try setting alias and dylib path to select your desired g++ ?
0 Kudos
Sergey_M_Intel
Employee
846 Views

HI Ilya H,

You should pass -gcc-version=470 option to compiler (by default compiler uses another gcc compatibility version).

Also, you should pass correct gcc's include directories to icc compiler. You can determine correct include directories from macports' gcc execution with '-v' argument. gcc will print something like that:

....

 /opt/local/include/gcc48/c++/
 /opt/local/include/gcc48/c++//x86_64-apple-darwin12
 /opt/local/include/gcc48/c++//backward

.....

You should add first two directories to icc command line (with -I prefix, see example below).

 

I've executed (I've got gcc4.8 from macports):

$ icc t.cpp -I /opt/local/include/gcc48/c++/x86_64-apple-darwin12/ -I /opt/local/include/gcc48/c++/ -std=c++11  -gcc-version=480
$ echo $?
0

 

---Sergey

0 Kudos
Ilja_H_
Beginner
845 Views

Thanks the includes and -gcc-version helped, although icc is complaining that -gcc-version is deprecated. The replacement according to icc -help deprecated should be -gcc-name but that doesn't seem to work:

icpc -std=c++11  -gcc-version=480 -I /opt/local/include/gcc48/c++/x86_64-apple-darwin13 -I /opt/local/include/gcc48/c++ a.cpp
icpc: command line remark #10010: option '-gcc-version=480' is deprecated and will be removed in a future release. See '-help deprecated'

icpc -std=c++11  -gcc-name=480 -I /opt/local/include/gcc48/c++/x86_64-apple-darwin13 -I /opt/local/include/gcc48/c++ a.cpp
In file included from /opt/local/include/gcc48/c++/array(35),
                 from a.cpp(1):
/opt/local/include/gcc48/c++/bits/c++0x_warning.h(32): catastrophic error: #error directive: This file requires...

Same error with ...-gcc-name=/opt/local/bin/g++-mp-4.8... and ...-gcc-name=g++-mp-4.8...

 

0 Kudos
Kittur_G_Intel
Employee
845 Views

Hi,

Try to ensure you specify location as well in the option like below.

           -gxx-name=/x/y/bin/g++  (for c++)

           -gcc-name=/x/y/bin/gcc  (for c)

The compiler looks for the g++ compiler named g++ in the path specified above and try it out....

_Regards, Kittur

0 Kudos
Andrey_B_Intel2
Employee
845 Views

Hi Ilja,

Ilja H. wrote:
Thanks the includes and -gcc-version helped, although icc is complaining that -gcc-version is deprecated. The replacement according to icc -help deprecated should be -gcc-name but that doesn't seem to work

You are right -- -gcc-name is not a full replacement for -gcc-version. I agree that the help message is misleading in this regard. Thanks for noticing this -- it will be fixed in a future compiler update.

Yours,
Andrey
 

0 Kudos
Kittur_G_Intel
Employee
845 Views

Thanks Andrey, the message is misleading... Also, since gcc is used from macports, the gcc-name option may not work correctly...

0 Kudos
Andrey_B_Intel2
Employee
845 Views

Ilja,

We investigated this a bit more. It seems that -gcc-name does work fine

BUT

you also need to explicitly tell the compiler that you don't want to use clang environment:

-gcc-name=/x/y/bin/gcc -no-use-clang-env

Andrey
 

0 Kudos
Ilja_H_
Beginner
845 Views

Thanks that works.

0 Kudos
Kittur_G_Intel
Employee
845 Views

Yes Andrey, it works after adding  -no-use-clang-env

Thanks,
Kittur

0 Kudos
Reply