Community
cancel
Showing results for 
Search instead for 
Did you mean: 
suanhwee
Beginner
168 Views

how do i know if program is compiled by g++ or intel compiler

Jump to solution
Hi,
Is there a define that intel compiler or g++ sets to inidicate that the program is compiled by the intel compiler or g++ can i detect it during runtime from the source code?
I have been looking around but i just cant find those defines.
Thanks
0 Kudos
1 Solution
TimP
Black Belt
168 Views
Quoting - suanhwee
Is there a define that intel compiler or g++ sets to inidicate that the program is compiled by the intel compiler or g++ can i detect it during runtime from the source code?
I have been looking around but i just cant find those defines.
Look up the pre-defined macros in the icc documentation, if that is your interest.

View solution in original post

5 Replies
aazue
New Contributor I
168 Views
Quoting - suanhwee
Hi,
Is there a define that intel compiler or g++ sets to inidicate that the program is compiled by the intel compiler or g++ can i detect it during runtime from the source code?
I have been looking around but i just cant find those defines.
Thanks
Hi
Use ldd /path..../program function system() in your source or in shell (easy side).
see also source ldd.
Add futures in your source an parameter for name compiler main(.... argv.... better.
Kind regards
If program call money licence is Icc....

TimP
Black Belt
169 Views
Quoting - suanhwee
Is there a define that intel compiler or g++ sets to inidicate that the program is compiled by the intel compiler or g++ can i detect it during runtime from the source code?
I have been looking around but i just cant find those defines.
Look up the pre-defined macros in the icc documentation, if that is your interest.

View solution in original post

suanhwee
Beginner
168 Views
Quoting - tim18
Look up the pre-defined macros in the icc documentation, if that is your interest.
thanks for helping me out
Dale_S_Intel
Employee
168 Views
Quoting - suanhwee
Hi,
Is there a define that intel compiler or g++ sets to inidicate that the program is compiled by the intel compiler or g++ can i detect it during runtime from the source code?
I have been looking around but i just cant find those defines.
Thanks

Forgive me if your question has already been answered, but I thought I'd add some clarification just in case. There are at least two ways I can interpret your question. If you want to tell at compile time, i.e. in the source while it's being compiled, that's pretty straightforward. The recommended macro to rely on is __INTEL_COMPILER, which is set to the compiler version (e.g. the 11.1 compiler is 1110). If that is defined, you know you're building with the Intel compiler. The other question you might be asking is if you've got an executable, can you tell if it was built with icc or gcc, that's trickier. If you're building the exceutable you can build something into it to answer that question at runtime using the above mentioned macro. If you've got a mystery executable and you're wondering how it was built, well that's a more complicated question.

Hope that helped.

Dale

TimP
Black Belt
168 Views
The other question you might be asking is if you've got an executable, can you tell if it was built with icc or gcc, that's trickier. If you're building the exceutable you can build something into it to answer that question at runtime using the above mentioned macro. If you've got a mystery executable and you're wondering how it was built, well that's a more complicated question.


In a gcc built object, you would expect an ascii string such as "gcc compiled," which you could see with the strings command. If you wished an embedded string from an icc compile, you could use -sox, or, as Dale said, put one in yourself.
A dead give-away is the presence or absence of the _intel_ run-time library functions in place of standard glibc equivalents.
Reply