使用Intel MKL编译C代码:ld:未知选项:--no-as-needed

我写了一个使用MKL Intel库(已经安装)的C文件(template.c)。我正在使用此Shell脚本来编译我的代码(template.c)。假设C文件很小-它导入了MKL库并具有一个主要功能-就这样。

source /opt/intel/compilers_and_libraries_2019.5.281/mac/mkl/bin/mklvars.sh intel64
gcc-9 -fopenmp -m64 -I${MKLROOT}/include -c template.c
gcc-9 -L${MKLROOT}/lib -Wl,--no-as-needed -lmkl_intel_lp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl template.o -o template
./template

但是,在Mac(Intel 64位处理器)上出现以下错误:

  

ld:未知选项:--no-as-need

任何暗示为何会发生这种情况?我正在使用Homebrew的最新GCC版本。

脚本的第一行提供脚本使用的环境变量,例如$MKLROOT。之后,它应该创建一个目标文件并最终运行名为template的可执行文件。

shenghuat 回答:使用Intel MKL编译C代码:ld:未知选项:--no-as-needed

请确保已为选定的接口层使用了推荐的编译器选项。

  

警告:将英特尔(R)MKL库与为以下目的编译的对象链接   不同的接口层可能会导致运行时错误。

供参考,请通过以下链接:

英特尔MKL链接线路顾问https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

本文链接:https://www.f2er.com/3008419.html

大家都在问