英特尔 icc 在 Linux 上使用 math.h 破坏了 gcc

英特尔 icc 在 Linux 上使用 math.h 破坏了 gcc

前几天,我安装了 Intel 的编译器和与 Parallel Studio 捆绑在一起的应用程序,如果不使用 icc,我就无法编译。使用 gcc、clang 或 mpicc 时,我收到以下错误:

In file included from z.main.c:13:0:
/opt/intel/include/math.h:29:3: error: #error "This Intel <math.h> is for
use with only the Intel compilers!"
# error "This Intel <math.h> is for use with only the Intel compilers!"
   ^
  main

通常我必须math.h使用 链接到库-lm,这适用于其他文件。我测试过的其他情况不包括mpi.h,如果有关系的话。

我不想卸载英特尔编译器;我希望在通过 ssh 进行远程工作之前,先解决本地遇到的任何问题。

更新

我跑去gcc fvm.c -c --trace -lm看看它在哪里寻找数学库。结果如下:

gcc z.fvm.c -c --trace -lm
. /usr/include/stdio.h
.. /usr/include/features.h
... /usr/include/x86_64-linux-gnu/sys/cdefs.h
.... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/gnu/stubs.h
.... /usr/include/x86_64-linux-gnu/gnu/stubs-64.h
.. /opt/intel/include/stddef.h
.. /usr/include/x86_64-linux-gnu/bits/types.h
... /usr/include/x86_64-linux-gnu/bits/wordsize.h
... /usr/include/x86_64-linux-gnu/bits/typesizes.h
.. /usr/include/libio.h
... /usr/include/_G_config.h
.... /opt/intel/include/stddef.h
.... /usr/include/wchar.h
... /opt/intel/include/stdarg.h
.. /usr/include/x86_64-linux-gnu/bits/stdio_lim.h
.. /usr/include/x86_64-linux-gnu/bits/sys_errlist.h
. /usr/include/stdlib.h
.. /opt/intel/include/stddef.h
.. /usr/include/x86_64-linux-gnu/bits/waitflags.h
.. /usr/include/x86_64-linux-gnu/bits/waitstatus.h
... /usr/include/endian.h
.... /usr/include/x86_64-linux-gnu/bits/endian.h
.... /usr/include/x86_64-linux-gnu/bits/byteswap.h
..... /usr/include/x86_64-linux-gnu/bits/wordsize.h
..... /usr/include/x86_64-linux-gnu/bits/byteswap-16.h
.. /usr/include/x86_64-linux-gnu/sys/types.h
... /usr/include/time.h
... /opt/intel/include/stddef.h
... /usr/include/x86_64-linux-gnu/sys/select.h
.... /usr/include/x86_64-linux-gnu/bits/select.h
..... /usr/include/x86_64-linux-gnu/bits/wordsize.h
.... /usr/include/x86_64-linux-gnu/bits/sigset.h
.... /usr/include/time.h
.... /usr/include/x86_64-linux-gnu/bits/time.h
... /usr/include/x86_64-linux-gnu/sys/sysmacros.h
... /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h
.... /usr/include/x86_64-linux-gnu/bits/wordsize.h
.. /usr/include/alloca.h
... /opt/intel/include/stddef.h
.. /usr/include/x86_64-linux-gnu/bits/stdlib-float.h
. /opt/intel/include/math.h
.. /usr/include/math.h
... /usr/include/x86_64-linux-gnu/bits/huge_val.h
... /usr/include/x86_64-linux-gnu/bits/huge_valf.h
... /usr/include/x86_64-linux-gnu/bits/huge_vall.h
... /usr/include/x86_64-linux-gnu/bits/inf.h
... /usr/include/x86_64-linux-gnu/bits/nan.h
... /usr/include/x86_64-linux-gnu/bits/mathdef.h
... /usr/include/x86_64-linux-gnu/bits/mathcalls.h
... /usr/include/x86_64-linux-gnu/bits/mathcalls.h
... /usr/include/x86_64-linux-gnu/bits/mathcalls.h
In file included from fvm.c:10:0:
/opt/intel/include/math.h:29:3: error: #error "This Intel <math.h> is for
use with only the Intel compilers!"
# error "This Intel <math.h> is for use with only the Intel compilers!"
   ^
. /usr/include/time.h
.. /opt/intel/include/stddef.h
.. /usr/include/x86_64-linux-gnu/bits/time.h
.. /usr/include/xlocale.h
. fvm.h
. lab_mpi.h
Multiple include guards may be useful for:
/usr/include/wchar.h
/usr/include/x86_64-linux-gnu/bits/byteswap-16.h
/usr/include/x86_64-linux-gnu/bits/byteswap.h
/usr/include/x86_64-linux-gnu/bits/endian.h
/usr/include/x86_64-linux-gnu/bits/huge_val.h
/usr/include/x86_64-linux-gnu/bits/huge_valf.h
/usr/include/x86_64-linux-gnu/bits/huge_vall.h
/usr/include/x86_64-linux-gnu/bits/inf.h
/usr/include/x86_64-linux-gnu/bits/mathdef.h
/usr/include/x86_64-linux-gnu/bits/nan.h
/usr/include/x86_64-linux-gnu/bits/select.h
/usr/include/x86_64-linux-gnu/bits/sigset.h
/usr/include/x86_64-linux-gnu/bits/stdio_lim.h
/usr/include/x86_64-linux-gnu/bits/stdlib-float.h
/usr/include/x86_64-linux-gnu/bits/sys_errlist.h
/usr/include/x86_64-linux-gnu/bits/typesizes.h
/usr/include/x86_64-linux-gnu/bits/waitflags.h
/usr/include/x86_64-linux-gnu/bits/waitstatus.h
/usr/include/x86_64-linux-gnu/gnu/stubs-64.h
/usr/include/x86_64-linux-gnu/gnu/stubs.h
fvm.h
lab_mpi.h

我如何告诉 gcc、mpicc 在哪里查找并忽略英特尔数学库?

提前致谢。

答案1

Intel header 是兼容的,但需要做一点小改动。首先,你需要关闭错误源。

//#if !defined(__INTEL_COMPILER)
//# error "This Intel <math.h> is for use with only the Intel compilers!"
//#endif

那么您应该包括缺少的标题。

#include <features.h>

相关内容