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

Newbie question on setting environment variables and linking

Charles_L_
Beginner
865 Views

Hi,

I just downloaded and installed Intel MKL on my Windows 10 machine. I'm trying to follow instructions on this page so that I can get started:

https://software.intel.com/en-us/articles/intel-mkl-113-getting-started"

I presume that, as in manual installation of LAPACK, gfortran, etc, which I had done before, I need to add the path to the MKL library in my environment variables (Control Panel -> System -> Advanced System Settings -> 'Advanced' tab -> Environment Variables -> Add/Edit). Am I correct? What should be the path?

I tried to follow the instructions above, but was confused.

There it says:

"A script (batch file on Windows, shell script on other platforms) located in the <mkl install directory>>\ compilers_and_libraries_2016\windows\mkl\bin\ directory (by default, it is C:\Program Files (x86)\IntelSWTools\ compilers_and_libraries_2016\windows\mkl\bin\)  can be used to set the MKLROOT, LIB, INCLUDE and any required system-specific environment variables to point to the appropriate MKL library directories."

I can locate this easily. But when I try to run things like

mklvars ia32

in that folder through Command Prompt, I really don't get anything. Am I doing the right thing anyway?

The instructions also say

"On a Windows system the following batch files are available to configure the environment for building Intel MKL applications:

mkl\bin\mklvars.bat  <arch>

or

IA-32 Intel® Architecture:  \mkl \bin\ia32\mklvars_ia32.bat
Intel® 64 Architecture:  \mkl \bin\intel64\mklvars_intel64.bat
"

I presume that the MKLROOT directory is C:\Program Files (x86)\IntelSWTools\ compilers_and_libraries_2016\windows\mkl\bin\, but I can't find the folders ia32 and intel64, or the files mklvars_ia32.bat and mklvars_intel64.bat anywhere.

So how should I set the environment variables so that I can compile my source code files through gfortran in Command Prompt? What line should I use to compile and link in Command Prompt?

Thanks.

 

0 Kudos
2 Replies
TimP
Honored Contributor III
865 Views

Unfortunately, mkl for windows isn't set up for use with gfortran. For use with msvc++, the .bat script ought to add the relevant entries in PATH and INCLUDE.  The mkl link advisor web app should give examples of the supported usages for linking.

You would not want permanent conflicting Windows environment variables for mkl and equivalent non-Intel libraries. 

There are pre-built open source libraries such as lapack compatible with some popular versions of gfortran which cover much of the features of mkl sequential. 

0 Kudos
Ying_H_Intel
Employee
865 Views

Hi Charles, 

Right, under windows,

for C language, MKL only support MSVC ++, or intel C/C++ compiler.  

for fortran language, only support PGI fortran compiler & Intel(R) Fortran Compiler. 

Under linux, it can support GNU g++ and gfortran. 

So you may try install one linux Virtual Machine, then try MKL + gfortran. 

Under Windows*: 
The command line is like below,
>\mkl\bin\mklvars.bat" ia32
>cl.exe mkl_lab_solution.c  mkl_intel_c.lib mkl_core.lib mkl_intel_thread.lib libiomp5md.lib

If with Intel Composer XE, as intel mkl is intergrated to it. The command line is simpler,
> icl.exe mkl_lab_solution.c /Qmkl

Under Linux:

if with gfortran
$source /opt/intel/mkl/bin/mklvars.sh ia32
$gfortran  a.for -Wl,--no-as-needed -L${MKLROOT}/lib/ia32 -lmkl_gf -lmkl_core -lmkl_sequential -lpthread -lm -ldl​

Best Regards,
Ying

 

0 Kudos
Reply