Software Archive
Read-only legacy content

icc and gcc

newport_j
Beginner
881 Views
Ihavesome files that compile perfectly under gcc, under icc not so much.

I took out the -lm and O compiler command options because it gave me warnings and when I took those command options for gcc out for icc it stopped warning me.

However, I am getting a lot of errors of "error: expected an expresion" type with a carrot placed under expressions like log10 , exp, sqrt. I believe it needs the Intel equivalent of -lm. What is it?

I replaced in my compile script gcc with icc. Then dropped -lm and then -O. I still get the expected an expression error andI am not sure what is the cause.

Also what is the icpc command. It must be different from icc.

Thanks in advance.

Newport_j
0 Kudos
9 Replies
TimP
Honored Contributor III
881 Views
You still need
#include
or
#include
or you will get the missing definition errors. If you use C++headers, you need icpc. Or, did you fail to follow math function names with a parameter list in ( )?
icpc is used the same way as g++, but with icc command line options. It's basically icc with C++ headers, syntax, and libraries. You don't need -lm with g++ or icpc; it's implied.
0 Kudos
Brandon_H_Intel
Employee
881 Views
What #includes are you using? I tried to reproduce by not including math.h, but gcc errors as well.
0 Kudos
newport_j
Beginner
881 Views
I was trying to answer your question about includes and created two files exp.c and power.c that can isolate the issue. They are attached with source.

I got an error /usr/include/libio.h(53): catastrophic error: cannot open source file "stdarg.h"
#include


compilation aborted for exp.c (code 4)

I guess in icc there is no stdarg.h in the include files. What is the workaround? I am sure this problem has arisen before and there are other ones that may bite me. Is there a paper that has all (or most) of the differences between icc and gcc like this?

Ant help appreciated.


Newport_j
0 Kudos
Brandon_H_Intel
Employee
881 Views
For the most part, icc does not provide its own include files (there are exceptions like math.h) - it just uses what comes with gcc/glibc. WhatLinux versionand gcc version are you using specifically, and also what version if icc (you can find this with icc -V)? I'm thinking there might be something unsupported somewhere, as I can compile/link/run both pow.c and exp.c fine (although I did have to specify -std=c99 on pow.c, which I had to do with gcc as well).
0 Kudos
Brandon_H_Intel
Employee
881 Views
There is also a whitepaper on gcc compatibility at http://software.intel.com/sites/products/collateral/hpc/compilers/intel_linux_compiler_compatibility_with_gnu_compilers.pdf which may help, but this seems a more basic problem than what would be addressed in there.
0 Kudos
newport_j
Beginner
881 Views

My gcc version is 4.2.4, my icc version 12.0.0. I am using Ubuntu 11.04 and I am using a Xeon quadcoreprocessor. As you can seeI am simply creating (making up) small programs that exemplify what is wrong in the main program. I hope to solve it on a 9 line program and not the 35,000+ line program.

Hence the use of exp.c and power.c.

Thanks for your help.I just want these two mini-progs to compile.


Newport_j

0 Kudos
newport_j
Beginner
881 Views


What does the commandsource compilervars.sh do?

I had to run this again this morning when I came in and typed in the password to unlock my screensaver.

I believe knowing that clearly may help.

Newport_j
0 Kudos
IDZ_A_Intel
Employee
881 Views
The two includes that seem consistent placed throughout the c functions (subprograms) are:

#include
#include


Some files math.h on them also, but not all.

Any help appreciated. Thanks in adavnce.


Newport_j
0 Kudos
Brandon_H_Intel
Employee
881 Views
Ok, I think I know the problem. The 12.0 compiler doesn't support Ubuntu 11.04. Can you upgrade to C++ Composer XE 2011 update 6 or later (current release is update 8, and update 9 should be coming soon) which contains the 12.1 compiler which does support 11.04 and see if that helps?
0 Kudos
Reply