Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

Compiling R with MKL

Alex8
Beginner
559 Views

Hi,

I'm trying to compile R 3.3.1 on Ubuntu Server 16.04 with Intel MKL using the GNU Fortran and C compilers. Unfortunately, I'm unable to get the gcc  to locate BLAS. I've tried several combinations of suggestions between those on the Intel website, including Build R-3.0.1 with Intel MKLUsing Intel MKL with R, and the Intel Link Advisor. I've also found some other bloggers who have successfully compiled R with MKL. Unfortunately, no one else's solutions have worked for me thus far.

I first ran the provided shell script to set the environment variables. I've noticed it's the INCLUDE variable is empty. Is this a problem, or did it happen by design? All others are appropriately created.

I've also been specifying the following LDFLAGS="-L$MKLROOT/lib/intel64" or LDFLAGS = "-L$MKLROOT/include" in order to point gcc to the directories. When I check config.log after the configuration, however, I see:

  • configure: 31659: checking for dgemm_ in -lblas
  • configure: 31692: gcc -o conftest -march=native -O3 -I/usr/local/include -L/opt/intel/compilers_and_libraries_2016.3.210/linux/mkl/include conftest.c -lblas -lgfortran -lm -lquadmath -lrt -ldl -l > &5
  • /usr/bin/ld: cannot find -lblas
  • collect2: error: ld returned 1 exit status

for both settings of the LDFLAGS. 

Any suggestions would be tremendously appreciated! Thank you for your time!

0 Kudos
2 Replies
Alex8
Beginner
559 Views

Hi again,

I was able to solve this problem with the following settings:

  • MKLROOT is set by the Intel-provided shell script
  • LDFLAGS="-L$MKLROOT/lib/intel64 -m64"
  • MKL="-L$MKLROOT/lib/intel64 -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_gnu_thread -lmkl_core -fopenmp -lpthread -lm -ldl"
  • ./configure --with-blas="$MKL" --with-lapack

Alex

0 Kudos
Ying_H_Intel
Employee
559 Views

Hi Alex, 

Glad to know you are able to solve the problem and thank you a lot for the sharing. 

Best Regards,

Ying 

0 Kudos
Reply