I wrote a C file (template.c) that uses the MKL Intel library (which I've already installed). I'm using this shell script to compile my code (template.c). Assume the C file is minimal - it imports the MKL library and has a main function - that's it.
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
However, I'm getting the following error on Mac (Intel 64-bit processor):
ld: unknown option: --no-as-needed
Any hints on why this may be happening? I'm using Homebrew's latest GCC version.
The first line of the script sources the environmental variables such as $MKLROOT
which are used by the script. After that, it should create an object file and eventually run the executable called template.